400 error via requests.json

Hey team!
can someone tell me why i getting 400 error in response?

:face_with_head_bandage:

Postman: response 200 ok

requests.json:

code:

response: status: 400

Hey @Nasir_Haidari,

From the Postman screenshot, the query object should have been -

"query": {
     "query":"agent_id:<%= context.id %>"
}

One quick check about e.id, can you console.log to check if the value is available?

Hey @zach_jones_noel!

Thanks for your reply! With your suggestion i getting this error:

  "agentsTickets": {
   "schema": {
     "method": "GET",
     "host": "<%= iparam.domain %>.freshservice.com",
     "path": "/api/v2/tickets/filter",
     "query": {
       "query": "agent_id:<%= context.id %>"
     },
     "headers": {
       "Authorization": "Basic <%= encode(iparam.api_key) %>",
       "Content-Type": "application/json"
     }
   }
 }

image

any ideas?

Does it work if you add an extra pair of quotes in the request template:

"query": {
       "query": "\"agent_id:<%= context.id %>\""
     },

This issue looks similar to:

2 Likes

Hey @kaustavdm & @zach_jones_noel !

Thanks for reply! your answer @kaustavdm worked great! thanks so much!
here is my query and response:

Query:

 const req = await client.request.invokeTemplate('agentsTickets', {
        context: {
          id: e.id,
        },
      });

requests.json:

  "agentsTickets": {
    "schema": {
      "method": "GET",
      "host": "<%= iparam.domain %>.freshservice.com",
      "path": "/api/v2/tickets/filter",
      "query": {
        "query": "\"agent_id:<%= context.id %>\""
      },
      "headers": {
        "Authorization": "Basic <%= encode(iparam.api_key) %>",
        "Content-Type": "application/json"
      }
    }
  },

and the Response:

image

once again thanks everyone!

2 Likes

@Nasir_Haidari, thanks for bringing this issue, the workaround is not the solution but our engineering team will be looking into this.

Will keep you posted. :slight_smile:

1 Like

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.