Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8300083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:25:12+00:00 2026-06-08T16:25:12+00:00

I am trying to update some custom fields using the REST API and PHP/cURL.

  • 0

I am trying to update some custom fields using the REST API and PHP/cURL.

I’m wondering if I might have edited something without realizing it, while what I have below “worked” yesterday (I think), it does not work now.

I get varying responses using the different “methods”, from:

  1. I get this one using the POST method, as it is uncommented below.

    HTTP 405 – The specified HTTP method is not allowed for the requested
    resource ().

  2. I get this one if I use the commented-out PUT method, with POST commented out.

    {"status-code":500,"message":"Read timed out"}
    
  3. And this one mixing and matching PUT and POST.

    {"errorMessages":["No content to map to Object due to end of input"]}
    

What am I missing/doing wrong? I am using the following code:

<?php

$username = 'username';
$password = 'password';

$url = "https://example.com/rest/api/2/issue/PROJ-827";
$ch = curl_init();

$headers = array(
    'Accept: application/json',
    'Content-Type: application/json'
);

$test = "This is the content of the custom field.";

$data = <<<JSON
{
    "fields": {
        "customfield_11334" : ["$test"]
    }
}
JSON;

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// Also tried, with the above two lines commented out...
// curl_setopt($ch, CURLOPT_PUT, 1);
// curl_setopt($ch, CURLOPT_INFILE, $data);
// curl_setopt($ch, CURLOPT_INFILESIZE, strlen($data));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");

$result = curl_exec($ch);
$ch_error = curl_error($ch);

if ($ch_error) {
    echo "cURL Error: $ch_error";
} else {
    echo $result;
}

curl_close($ch);

?> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T16:25:13+00:00Added an answer on June 8, 2026 at 4:25 pm

    The problem here is that PHP’s cURL API is not particularly intuitive.

    You might think that because a POST request body is sent using the following option
    that a PUT request would be done the same way:

    // works for sending a POST request
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    
    // DOES NOT work to send a PUT request
    curl_setopt($ch, CURLOPT_PUT, 1);
    curl_setopt($ch, CURLOPT_PUTFIELDS, $data);
    

    Instead, to send a PUT request (with associated body data), you need the following:

    // The correct way to send a PUT request
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    

    Note that even though you’re sending a PUT request, you still have to use the CURLOPT_POSTFIELDS
    option to send your PUT request body. It’s a confusing and inconsistent process, but it’s what you’ve
    got if you want to use the PHP cURL bindings.

    According to the relevant manual entrydocs, the CURLOPT_PUT option seems to only work for PUTting a file directly:

    TRUE to HTTP PUT a file. The file to PUT must be set with CURLOPT_INFILE and CURLOPT_INFILESIZE.

    A better option IMHO is to use a custom stream wrapper for HTTP client operations. This carries the
    added benefit of not making your application reliant on the underlying libcurl library. Such an
    implementation is beyond the scope of this question, though. Google is your friend if you’re interested
    in developing a stream wrapper solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to update some properties with KVC. The properties have been synthesized. This
Im trying to update the contents of an element after running some php code.
I'm trying to update the display brightness from a widget but i have some
I`m trying to display classes that have properties of type some custom class inside
I'm trying to open a Word template and update its fields using CustomDocumentProperties in
I am trying to update some hibernate code that was written by someone else
Hi I am trying to update a div with some html from another div.
i'm trying to make a ajax update in prototype with some values from a
I am trying to use drush to update my drupal core but in some
I'm trying to add some custom filter methods to my magento module. I though

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.