cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
273
Views
5
Helpful
7
Replies
Highlighted
Beginner

CVP Call Studio Rest_Client - POST body syntax

I am trying to post data to an external server but I can't seem to get the body of the request to work. I used multiple tools such as Postman and I am getting the result I need but all these tools understand multiple programming languages 

Here is what I need to post in the body

 

 

 

 

mutation {
  createCommunication(
    communication: {
      status: "needs_delivery"
      priority: ""
      category: ""
      reasonCode: "wayfinding"
      topic: ""
      note: ""
      medium: "sms"
      payload: [{ contentString: "Test" }]
      direction: "outbound"
      intent: "info"
      sessionID: ""
      recipient: [
        {
          resourceType: "Patient"
          telecom: [{ system: "phone", value: "646XXXXXXX", use: "mobile" }]
        }
      ]
    }
  ) {
    identifier {
      value
    }
  }
}

 

 

 

 

I was able to get this to work in UCCX Script Editor by following the syntax below 

 

 

 

u"{\"query\":\"# Write your query or mutation here\\nmutation {\\n createCommunication(\\n communication: {\\n status: \\\"needs_delivery\\\"\\n priority: \\\"\\\"\\n category: \\\"\\\"\\n reasonCode: \\\"wayfinding\\\"\\n topic: \\\"\\\"\\n note: \\\"\\\"\\n medium: \\\"sms\\\"\\n payload: [{ contentString: \\\"UCCX Testing\\\" }]\\n direction: \\\"outbound\\\"\\n intent: \\\"info\\\"\\n sessionID: \\\"\\\"\\n recipient: [\\n {\\n resourceType: \\\"Patient\\\"\\n telecom: [{ system: \\\"phone\\\", value: \\\"" + REST_callbacknumber + u"\\\", use: \\\"mobile\\\" }]\\n }\\n ]\\n }\\n) {\\n identifier {\\n value\\n }\\n}\\n}\\n\"}"

 

 

 

 

7 REPLIES 7
Highlighted
Rising star

When I enter your json into jsonpathfinder dot com - I get this error


There seems to be a problem with your JSON.
Error message: JSON.parse: unexpected character at line 1 column 1 of the JSON data


I've never seen valid json that has the format you posted.

Highlighted

What version of CVP do you have, there was a REST Client bug regarding post w/json a while back...

Highlighted

It'll also be helpful if you log the element data named status_code and response_body so we can see what the return error message actually contains

Highlighted

Janine - thanks for the reply. Here is more information 

 

JSON code that is valid by checking multiple tools but does not pass validation in call studio

{"query":"mutation {\n  createCommunication(communication: {status: \"needs_delivery\", priority: \"\", category: \"\", reasonCode: \"wayfinding\", topic: \"\", note: \"\", medium: \"sms\", payload: [{contentString: \"Hello World\"}], direction: \"outbound\", intent: \"info\", sessionID: \"\", recipient: [{resourceType : \"Patient\", telecom: [{ system : \"phone\", value: \"9171234567\", use: \"mobile\"}]}]}) {\n    identifier {\n      value\n    }\n    payload {\n      value\n    }\n  }\n}\n"}

Error on validation - it feels that is related to the area in regards to response values at the end 

Action Element: Rest_Client_01	Configuration error: The value of the setting "Body" contains substitution errors: "{\n      value\n}": Invalid Key: \n      value\n

You didn't say what version, but Janine might be right on the money as always, the brackets may be the problem if you're hitting this bug.

https://bst.cloudapps.cisco.com/bugsearch/bug/CSCve44607

Highlighted

replace all the \" with apostrophe '  (no back slash)

and remove the \n

Highlighted

The workaround may be to use the Set Value element to assign your json query into a LocalVariable. Then use the value of that LocalVariable in the rest client element Body Setting.

 

 

Content for Community-Ad