Fail with CURL PUT call with Zoho Subscription API using PHP

Fail with CURL PUT call with Zoho Subscription API using PHP

Hello 

I use the API provided by zoho in subscription and forms for my application. I got no problems for retreive any information and update my custormer data in Zoho Books but unfortunatly, that' not working for subscription.

This is my json array to update a subscription with a new addon 


  1. {
  2. "reference_id": "",
  3. "plan": {
  4. "plan_code": "MyDWS-FR-Basic",
  5. "name": "Abonnement de base",
  6. "price": 0,
  7. "quantity": 1,
  8. "tax_id": "",
  9. "setup_fee_tax_id": ""
  10. },
  11. "addons": [{
  12. "addon_code": "ADD_EN-Others1",
  13. "price": 0,
  14. "quantity": 1,
  15. "tax_id": ""
  16. }],
  17. "contactpersons": [{
  18. "contactperson_id": "264809000000126115"
  19. }]
  20. }

This is my call in my PHP app

  1. public function makePuTCurlQuery($query,$data){

    $curl = curl_init($query);

    curl_setopt_array($curl, array(
    CURLOPT_POST => 1,
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_POSTFIELDS => $data,
    CURLOPT_RETURNTRANSFER => true
    ));

    $response = curl_exec($curl);
    curl_close($ch);
    return $response;
    }

Content of my variables :

$query >  https://subscriptions.zoho.com/api/v1/subscriptions/My_working_subscription_id

$data >  

  1. array(3) {
    ["authtoken"]=>
    string(32) "my_working_authtoken"
    ["organization_id"]=>
    string(9) "my_working_organization_id"
    ["JSONString"]=>
    string(281) "{"reference_id":"","plan":{"plan_code":"MyDWS-FR-Basic","name":"Abonnement de base","price":0,"quantity":1,"tax_id":"","setup_fee_tax_id":""},"addons":[{"addon_code":"ADD_EN-Others1","price":0,"quantity":1,"tax_id":""}],"contactpersons":[{"contactperson_id":"264809000000126115"}]}"
    }

This is the result of the call with any others explaination > "The request passed is not valid."

Where i did a mistake ? This kind of call working like a charm for Books...

Cheers

Sébastien