Note that there are some explanatory texts on larger screens.

plurals
  1. POSalesforce creates record but responds with a 405
    primarykey
    data
    text
    <p>I've written a Wordpress Plug-in that interacts with Salesforce via the REST API. It successfully gets an Instance URL and an Authentication Token using a username/password.</p> <p>I'm able to submit queries and create objects using wp_remote_post with GET and POST respectively. </p> <p>However, when creating objects, though successfully created in the Salesforce instance, I get the following in response to my POST:</p> <blockquote> <p>{"message":"HTTP Method 'POST' not allowed. Allowed are HEAD,GET,PATCH,DELETE","errorCode":"METHOD_NOT_ALLOWED"}</p> </blockquote> <p>Using the same json body content from these requests, I am able to submit and create via the Salesforce Workbench with no problems at all. I get a proper response that looks like this:</p> <blockquote> <p>{ "id" : "003E000000OubjkIAB", "success" : true, "errors" : [ ] }</p> </blockquote> <p>Is there something in the Headers that I'm sending that Salesforce only partially disagrees with? Here are some other arguments that are getting sent as a result of using wp_remote_post - <a href="http://codex.wordpress.org/HTTP_API#Other_Arguments" rel="nofollow">http://codex.wordpress.org/HTTP_API#Other_Arguments</a></p> <p>Here's the php code that's calling it:</p> <pre><code>$connInfo['access_token'] = get_transient('npsf_access_token'); $connInfo['instance_url'] = get_transient('npsf_instance_url'); $url = $connInfo['instance_url'] . $service; $sfResponse = wp_remote_post($url, array( 'method' =&gt; $method, 'timeout' =&gt; 5, 'redirection' =&gt; 5, 'httpversion' =&gt; 1.0, 'blocking' =&gt; true, 'headers' =&gt; array("Authorization" =&gt; "OAuth ". $connInfo['access_token'], "Content-type" =&gt; "application/json"), 'body' =&gt; $content, 'cookies' =&gt; array() ) ); </code></pre> <p>The $content is being encoded via json_encode before it gets to this point.</p> <p><strong>Update:</strong> It is specific to one of the extra CURL options being sent by the WP_Http_Curl class. I haven't yet narrowed down which one Salesforce is having a problem with.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload