0
Error: call to URL https://cs31.salesforce.com/services/apexrest/CreateLoan/ failed with status 200, response HTTP/1.1 200 OK Date: Tue, 01 Mar 2016 08:18:26 GMT Set-Cookie: BrowserId=My_9dHEtQwGKzujO5w73-w;Path=/;Domain=.salesforce.com;Expires=Sat, 30-Apr-2016 08:18:26 GMT Expires: Thu, 01 Jan 1970 00:00:00 GMT Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked " message - Invalid Partner Code,", curl_error , curl_errno 0

And I am using following Code

{'access_token'};
create_account($name, $instance_url, $access_token);
function create_account($name, $instance_url, $access_token) {
    $url = $instance_url;
    //$content = json_encode(array("Name" => $name));

    $content='{"loanAppWrapper":
                {
                "location":"Mumbai",
                "lob":"PL",
                "createdBy":"Customer",
                "partnerName":"Company ABC",
                "firstName":"TestFirst",
                "lastName":"XYZ",
                "middleName":"XYZ",
                "loanSource":"PLOnline",
                "gender":"Male",
                "maritalStatus":"Single",
                "dateOfBirth":"11/12/1982",
                "mobileNumber":"9999999999",
                "emailId":"abc@sf.com",
                "PAN":"abcpk1241f",
                "voterId":"abc1234567",
                "passportNumber":"K1234567",
                "listAddress":
                [{"addressLine1":"addressLine1",
                "addressLine2":"addressLine2",
                "pincode":"400001",
                "addressType":"RESIDENCE ADDRESS",
                "landmark":"Near XYZ Store"}]
                }

                }';
    //echo $content;
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_HEADER, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER,
            array("Authorization: OAuth $access_token",
                "Content-type: application/json"));
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

    $json_response = curl_exec($curl);
    //echo $json_response;
    $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

    if ( $status != 201 ) {
        die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
    }

    echo "HTTP status $status creating account

"; curl_close($curl); $response = json_decode($json_response, true); echo $response; $id = $response["id"]; echo "New record id $id

"; return $id; } ?>
  • seems u r calling a custom apex rest api from salesforce which is expecting partnerCode in the request.. in the $content you are passing in, I can see you are setting partnerName already.. if you have the Code for the partner, set it to partnerCode next to it and see if it works. – Vamsi Krishna Mar 1 '16 at 8:26
0

It appears that there is no issue with your(PHP) code.

To confirm that there is not issue with your code I have refereed cookbook recipe. http://developer.force.com/cookbook/recipe/interact-with-the-forcecom-rest-api-from-php

So, I leads me to think that this error is returned by Rest API.

There is easy way to verify above understanding.

login to https://workbench.developerforce.com/restExplorer.php and got to utilities -> Rest Explorer

Then enter your api URL as https://cs31.salesforce.com/services/apexrest/CreateLoan

And enter your json data click subumit. If you get same error its probably issue with Rest API(or may be data validation in api )

  • Thanks @Vamsi Krishna and AtulRajguru. It resolves my error and I am getting application number now. I just want to ask, I am getting this application mumbar with this error"Error: call to URL cs31.salesforce.com/services/apexrest/CreateLoan failed with status 200, response HTTP/1.1 200 OK Date: Tue, 01 Mar 2016 08:30:01 GMT Set-Cookie: BrowserId=1XBCUON2SLyQSlrJCmI_7g;Path=/;Domain=.salesforce.com;Expires=Sat, 30-Apr-2016 08:30:01 GMT Expires: Thu, 01 Jan 1970 00:00:00 GMT Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked "success: Loan Application Number - 8043 – Priyanka Gurav Mar 1 '16 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.