cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1443
Views
13
Helpful
5
Replies

Correct Format for using REST Client

Hi All,

I am struggling to get the format correct for my POST using the CVP REST Client (CVP 11).  I am just using the API to send an SMS message and had it working in Postman immediately but cannot seem to get the correct format in CVP.  I am getting a response but I am missing one of the required parameters. I have tried this API using both JSON and XML by changing the content type in the header and I can see the response coming back in both formats as I change the header type..  I have tried putting these values in both the parameter field and the body field in the CVP element with no success.  I always get the same response  as shown below which is ' a From phone number is required'

The API is expecting a from and a to phone number in E.164 format

10.XXX.XX.31.1525133209662.198.TEST1,05/01/2018 10:06:51.298,POST_Rest_Client_01,custom,log return,<?xml version='1.0' encoding='UTF-8'?>

<TwilioResponse><RestException><Code>21603</Code><Message>A 'From' phone number is required.</Message><MoreInfo>https://www.twilio.com/docs/errors/21603</MoreInfo><Status>400</Status></RestException></TwilioResponse>

My question is where should I be focusing?  Is it in the parameters field of the CVP element or the body?  ( I have tried many variations like simply using From and the phone number or trying to use the xml form such as this  <From>+61XXXXXXXXX</From>  I have also tried the JSON format {"From": "+61xxxxxxxxx)"

I have also tried all of this just in the body parameter of the element - so far with no success.  Any help would be appreciated such as examples of use of sending JSON and/or XML using this element. I am just adding the values in statically until I get it working and will change them to session data later.  I have seen one other example on the forum of the google geolocater API and that works and I can see that is uses the parameter field.  That was GET rather than POST so I am just wondering if there is any difference with POST

I have attached my current settings of the element

Thanks in advance!

Cathal


1 Accepted Solution

Accepted Solutions

Hi everyone

I am pleased to say this is finally working.  The issue was that the API would only accept form data in key-value pairs and the trick was to get the raw data (string)  to create this form data.  The way to do is to use" ="

In the example above to create the "From", you use From=xxxxxxxx. To create a second field you need to use"&"

I needed 3 parameters in total for this POST request so I had to use From=xxxxxxx &To=xxxxxxx &Body=xxxxxxxxx

Another issue I ran in to was that you could not send "+" which was required as I needed the phone number in  E164  format.  To get around this you have to use the Hex equivalent of t