Mark a draft estimate as sent => The request passed is not valid

Mark a draft estimate as sent => The request passed is not valid

Hi,
I encountered some issues to create estimates or invoices because they keep being registered as 'draft',
whereas my parameters aren't for drafts.
I use Apps Script to make my requests. Here the code to create an estimate with 'sent' status but I still get a draft :

  1. var json = {
  2. "customer_id": clientIdZoho,
  3. "template_id": templateZohoIdDevis,
  4. "name": zohoItem.name,
  5. "date": dateDevisCreation,
  6. "expiry_date": dateDevisFin,
  7. "line_items": [{
  8. "item_id": zohoItem.item_id,
  9. "description" : description,
  10. "rate":prix,
  11. "quantity": quantite,
  12. "tax_id": zohoItem.tax_id,
  13. "tax_name": zohoItem.tax_name,
  14. "tax_percentage": zohoItem.tax_name
  15. }]
  16. ,
  17. "status": "sent",
  18. "send" : true,
  19. };
  20. }
  21. var options = {
  22. 'method': 'POST',
  23. 'headers' : {
  24. 'Authorization': 'Zoho-oauthtoken '+accessToken,
  25. 'X-com-zoho-invoice-organizationid': ORGANIZATION_ID_V2,
  26. 'Content-Type' : 'application/json'
  27. },
  28. 'payload' : JSON.stringify(json),
  29. 'muteHttpExceptions' : true
  30. }
  31. var resultat = UrlFetchApp.fetch(url,options);

I decided to change my plan and to use the request given by the api to change its state after being created. However, I keep getting the error code : 2, "The request passed is not valid." . I tried with ARC (similar to postman) and it worked with the same parameters, but still not in my code. Here my code :

  1. function setDevisAsSend(idDevis){
  2. var idDevis = "--------";//JSON.parse(resultat.getContentText()).estimate.estimate_id;
  3. var accessToken =getZohoAccessToken();
  4. var url='https://invoice.zoho.com/api/v3/estimates/'+idDevis+'/status/sent?X-com-zoho-invoice-organizationid=-----';
  5. var options = {
  6. 'method': 'POST',
  7. 'headers' : {
  8. 'Authorization': 'Zoho-oauthtoken '+accessToken,
  9. 'Content-Type' : 'multipart/form-data'
  10. },
  11. 'muteHttpExceptions' : true
  12. }
  13. Logger.log(url);
  14. Logger.log(options);
  15. var response = UrlFetchApp.fetch(url, options);
  16. Logger.log(response);
  17. }

I already use the same syntax for other resquests and it works, my scope is correct and
the access token is valid too. I would really appreciate any help !


Here an exemple of an other request working well :

  1. var accessToken =getZohoAccessToken();
  2. var url='https://invoice.zoho.com/api/v3/contacts';
  3. var options = {
  4. 'headers' : {
  5. 'Authorization': 'Zoho-oauthtoken '+accessToken,
  6. 'X-com-zoho-invoice-organizationid': ORGANIZATION_ID_V2,
  7. 'Content-Type' : 'multipart/form-data'
  8. },
  9. 'muteHttpExceptions' : true
  10. }
  11. var response = UrlFetchApp.fetch(url, options);