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);

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation
                                          • Topic Participants

                                          • Dev

                                              • Sticky Posts

                                              • How to Add Users to your Organization in ZohoMail?

                                                A better clarity so you can create other users to start using Zoho Mail. You can directly Add Users from the Control Panel to your Organization. You can invite users with the existing email address. If the person (user) already uses ZohoCRM, then you can import users from Zoho CRM. You can also import them using a .csv file. (if you are planning to add them in Bulk)  In this topic, We will be discussing on how to Add and Invite users only.  The Import options are self explanatory. ____________________________________________________________________________________________________________


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now