cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
5240
Views
15
Helpful
22
Replies
Highlighted
Beginner

UCCX 10.6 - Make REST Call

Hi everyone,

I'm currently struggeling with the "Make REST Call" step in CCX Script.
Within the REST step properties, we can select the Method and Parameters.

I need to do a POST to another database.
Problem is that when I add parameters, then these will be added to the Request URI instead to be put in the body. 

However, when I want to add the "parameters" in the body field then script editor doesn't allow me to do so.
I'm even not sure which format CCX is expecting there as everything I've tried has been rejected by the Editor...

Compared to the Postman Code, where we have the Body included, it's not working correctly with the CCX script. 
Here's a snippet from Postman in code format: 

POST any address HTTP/1.1
Host: any host
Authorization: Basic 
Cache-Control: no-cache
Postman-Token: xxxxx
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="messageTypeCode"

any value
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="originTelNumber"

any number
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="targetUser"

any user
------WebKitFormBoundary7MA4YWxkTrZu0gW--

Compared to the actual Request by CCX, it is looking in Wireshark the following: 

Request URI Query: messageTypeCode=any value&originTelNumber=any number&targetUser=any user3DCall+Manager+User%2Cid%3Danyuser%2Cauthenticated%3Dtrue%5D

How do I get these "content-disposition" fields above into the actual POST request by CCX Script correctly?

Any Idea? 

Thanks in advance
Michael

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Collaborator

Hi cant you do it by attaching those in body?

see attached, see if it gives you some idea.

View solution in original post

Highlighted

In Postman the content disposition is passed in "":

Content-Disposition: form-data; name="messageTypeCode"
Content-Disposition: form-data; name="originTelNumber"
Content-Disposition: form-data; name="targetUser"

In your UCCX script its passed without "":

Content-Disposition: form-data; name=messageTypeCode
Content-Disposition: form-data; name=originTelNumber
Content-Disposition: form-data; name=targetUser

so try appending +"\""+ before those name to convert them into string.

Try to correct and see if it works

View solution in original post

22 REPLIES 22
Highlighted
Collaborator

Hi cant you do it by attaching those in body?

see attached, see if it gives you some idea.

View solution in original post

Highlighted

attaching the uccxcap1.png again which shows how to separate line to get desired wire-shark results.

Highlighted

Hi Chintan,

Thanks for the help on that. So, I'm able to add a Body now, That's fine, but if we see your script as example... at the Point "some_vaue" , I would need to have the value of a variable (String).

I tried it with (probably wrong) String.valueOf("AgentID") but in this case it is just adding "AgentID" :)

What would be the correct command to reference from the value of a variable?

Thanks

Highlighted

You have to collect AgentID in some String variable and later you can use All Variable drop down in order to substitute any variable.

if you pass it in "" it becomes string, and if you want pass the variable value along with "" then see attached.

Its kind of same what you do in Java, you will find it easy if you have previous experience on Java. And also please do rate all helpful post if helps.

Highlighted

Yeah, you are right... sorry.

I added AgentID+ instead of AgentID +

Stupid...

I'm going to check that now also for the other values.

Also I have to modify the value of AgentID as I reference it from the "Select Resource" Step "Resource Selected". It does Show me the Agent ID but the Format is
User[type=Call Manager User,id=xxxxxx,authentication=true]

The plan was that Only xxxxxx will be displayed :)

Highlighted

please use get user info step.

imput the user you have got from select resource step and extract the id in different variable.

Highlighted

That worked out, Thanks.

The Body Looks fine now, more or less as with Postman.

However, the receiving end is dropping me with a "RESTEASY003065: Cannot consume Content type"

But it's set to application/json .

Funny: When the Body is empty, it says 200 OK. Will Need to dig deeper into it.

Highlighted

you got to set content type to "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"

where the value after "boundary=" should match what you use in body to separate the different parameters.

also the snap I posted earlier only has partial body covered, you have to edit tbe script in your own way to match the body.

Highlighted

So, I have adjusted the Script but it's still failing. 

Please have a look on the attached text file, where I have included the TCP Stream for working (via Postman) and non-working scenario (via CCX).

There are slightly differences but I think the most important part is the "Accept-Header" field... any conclusion? 

Highlighted

In Postman the content disposition is passed in "":

Content-Disposition: form-data; name="messageTypeCode"
Content-Disposition: form-data; name="originTelNumber"
Content-Disposition: form-data; name="targetUser"

In your UCCX script its passed without "":

Content-Disposition: form-data; name=messageTypeCode
Content-Disposition: form-data; name=originTelNumber
Content-Disposition: form-data; name=targetUser

so try appending +"\""+ before those name to convert them into string.

Try to correct and see if it works

View solution in original post

Highlighted

I have corrected the values and they are now correct. However, the remote end is still error me on the Accept Header.

Content-Type and Accept are the same. With Postman they are different.

The only difference in error message type is:

1. When I put as content-type "application/json", script is putting that into Content-Type and Accept. The remote is saying "Cannot consume content Type" 

2. When I put as content-type "multipart/form-data; boundary......", script is putting that into content-type and accept. The remote is saying "Cannot consume accept header"

It makes me crazy :/

Highlighted

aah that's something i see as a limitation with UCCX, it is may be not able to handle content-type and Accept headers having separate values. it always sets both as same.

You now have two option:

1) talk to your developer and ask him to convert the service to more simplistic where you can send request in json or xml and have response also in same format.

2)if 1 does not work, we have to go and do custom java class which can do the job eventually.

Highlighted

Hi Chintan, 

thanks for the overall support for now. I will talk with the developers to see what they can do. Will come back on that once I have new information.

Cheers

Michael

Highlighted

Hey Micheal, i my self wasn't convinced with the abrupt ending of the thread.

and was trying over the weekend on how this can be still done gracefully without doing external java/jar. and looks like with UCCX in built ability to do java is enough and the post can be done with just simple set node :).

attaching the script, though it has everything hard coded, you can go step by step and change those hard coding to variables.

Now i am somewhat convinced.