Sending post-call as json-raw not working

Hello! I’m trying to make a post-call of the API Callpicker, I read the documentation and it says this is the format:
image

JSON CODE:

{
   "token":"2066259308b7d9902bb897836616ed5f85bcaaacd577592f0d4b85822ba3ba2f345b0052c223f20071f5105cbf2e0d089c2edbb3ec4b9d24b07a7de21b9736d8",
   "datetime":"now",
   "first_call":"{'destination_type':'Extension','destination_id':'201539'}",
   "second_call":"{'destination_type':'Phone','destination_id':'473884753'}",
   "preferred_trunk":"524831115864"
}

this post-call return the next error:

Also I tried using form-data like this:
Headers


Body

but it shows an error in the parameter first_call…

I read several posts but it didn’t work :frowning:
Any suggestions? Thanks in advance!!

Hi @descent-module-pilo6

That example is JSON, not key/value pairs.
Try changing your request body to “raw” and then set the format as JSON.
Then copy in the values as per the example;

{
    "token":"2066259308b7d9902bb897836616ed5f85bcaaacd577592f0d4b85822ba3ba2f345b0052c223f20071f5105cbf2e0d089c2edbb3ec4b9d24b07a7de21b9736d8",
    "datetime":"now",
    "first_call":"{'destination_type':'Extension','destination_id':'201539'}",
    "second_call":"{'destination_type':'Phone','destination_id':'4731938483'}",
    "preferred_trunk":"524831115864"
}

eg:

Hi @w4dd325 Thanks for your reply!

I tried to run it as raw-json but still it shows this error:

Is there a link to the documentation?

Sure! Callpicker dial API
This is the documentation

Authorization I run it like this and it works:

Do you have anything defining “now”?

the format should be: “datetime”: “2022-03-23 11:34:00”,

but yours is “datetime”: “now”,

This will likely be passing a sting “now” instead of an actual timestamp.

According to the blurb, the datetime is a string.

When to place the call.

  • If format Y:m:d h:m is used, the call will be scheduled to be dialed at that time.
  • if ‘now’ (without quotes) is used, the call is dialed immediately.

Therefore, it looks like its ok.

It looks like it just needs the access_token from the OAuth request to be set as an environment or collection variable (called access_token or token).

Then in the raw\json request, get it to use this token.

"token": {{access_token}} // or
"token": {{token}}

It does look like it’s been manually pasted into the next request, so it should be working.
Don’t know how long those tokens last for though.

According to the blurb for that API, a 400 response code can be an expired token.
403 is an invalid token.
400 is usually a generic catch all though, so I’m not sure how accurate this is.

It does say that parameters must be sent as form-data params. Therefore raw\json may be incorrect. Try x-www-form-urlencoded or form data (similar to your token request).

I missed the note about form data, but the comment about ‘now’ in quotes …

‘now’ in the screenshot is in quotes;
image

… I agree that the token could be expired

The time at which this screenshot was shared…
image
I believe the token had expired;
image

As the blurb says that datetime is a string, then I assumed that it does need quotes. I think the blurb is unclear. I would just test it though, with and without. You never know.

Hi, @mdjones @w4dd325 thanks for your replies!!!

Yeah as you said the token I generated with this api-call

Manually I copied and paste the token into the raw_json api-call dial
this token has a duration of 10mins but all the tests I made was in a correct time duration

The parameter now is defined in the documentation and yes it triggers a format date time in the current time of the api-call

I think the format should be incorrect… because even if I send a blank JSON as api-call I receive de same error “Undefined parameter token”

@descent-module-pilo6

I think it has to be form-data or x-www-form-urlencoded, not raw json.

Therefore, it’s ignoring anything you have in the body.

Just try both options. It will be similar to the way you generate the token.

You can send the first_call and second_call data as JSON by selecting Content-Type as “application/json”. It will definitely work!

1 Like