Failing to enter the error block when freshdesk ticket API is called

Hello,

We are trying to call ticket api to catch the contact create event.This portion is working successfully.
But, when I give a wrong api key or invalid contact id to update in freshdesk, I am not getting any response.It is also not going to error block.I am testing this locally but hitting the actual api.

Please see the code below:

          
        var options = { method: 'PUT',
        url: freshdesk_url,
        headers:
        {'cache-control': 'no-cache',        
          authorization:  "Basic " + util.getFreshdeskAPIKey(payload),
          'content-type': 'application/json' },

          body: {
            "custom_fields": {
              "contact_info_from_odoo":newString
                      },
          },
          json: true };


        $request.put(freshdesk_url,options).then(
           function(data) {    
                console.log(data);               
           })           
             , error => {
                      console.log('Request to Freshdesk failed' + JSON.stringify(error));
             };
        })
1 Like

hey @JayaB,

Could you please try to make the same api call in Postman and check if you get a response and update in the thread?

2 Likes

hey,

This has been resolved.Please feel free to close the ticket.

Here is the correct code,

   $request.put(freshdesk_url,options).then(
           function(data) {    
                console.log(data);               
           }           
             , error => {
                      console.log('Request to Freshdesk failed' + JSON.stringify(error));
             });
        })

Moved the closing bracket after then to after error block.

Thank you for the prompt respsonse!

1 Like