Abilio_Puente | 2022-02-24 17:45:07 UTC | #1
Hi , I'm getting an error while testing my JSON in the data action " Resolve request body template: Substitution values invalid in action config. Variable $email has not been set at BodyTemplate[line 2, column 29] A common reason for this error is needing to prepend the variable with 'input.' or 'credentials.'"
This is my body: query getTrip($email : String!, $bookingId: Long!) { getTrip(email: $email, bookingId: $bookingId) { messages { bookingId type semantic ... on CancellationMessage { cancellations { cancellationStatus providerBookingItemId ... on Cancellation { incidents { flightNumber } } } } priority extraHeader } } }
Any help will be useful. Thank you!
Jason_Mathison | 2022-02-25 19:10:44 UTC | #2
Any chance you could post an export of your action (with anything sensitive replaced with XXXX or whatever)?
Abilio_Puente | 2022-02-28 09:42:52 UTC | #3
Thank You @jason_mathison. Here you have the requested info
{ "name": "XXX - Exported 2022-02-17 @ 7:48", "integrationType": "custom-rest-actions", "actionType": "custom", "config": { "request": { "requestUrlTemplate": "https://xxx/graphql", "requestType": "POST", "headers": {}, "requestTemplate": "{\n \"query\": \"query getTrip(\\$email : String!, \\$bookingId: Long!) {getTrip(email: \\$email, bookingId: \\$bookingId) {messages {bookingId type semantic ... on CancellationMessage { cancellations { cancellationStatus providerBookingItemId ... on Cancellation { incidents { flightNumber } } } } priority extraHeader } } }\",\n \"variables\": {\n \"bookingId\": \"1111111111\",\n \"email\": \"xxxxxx@gmail.com\"\n }\n}" }, "response": { "translationMap": {}, "translationMapDefaults": {}, "successTemplate": "${rawResult}" } }, "contract": { "input": { "inputSchema": { "type": "object", "properties": {}, "additionalProperties": true } }, "output": { "successSchema": { "type": "object", "properties": {}, "additionalProperties": true } } }, "secure": false }
Jerome.Saint-Marc | 2022-02-28 11:22:13 UTC | #4
Hello,
$ is a reserved keyword (to provide a reference to an input parameter or a credential token).
You would need to use Velocity macros for Data Actions to escape the $ character properly.
You can use something like the following (Data Action Configuration Request - as JSON). We set a variable d - equal to "$". In the request body, we can use {d} to insert the $ character.
{ "requestUrlTemplate": "https://xxx/graphql", "requestType": "POST", "headers": {}, "requestTemplate": "#set ( $d = $esc.dollar ){\n \"query\": \"query getTrip(${d}email : String!, ${d}bookingId: Long!) {getTrip(email: ${d}email, bookingId: ${d}bookingId) {messages {bookingId type semantic ... on CancellationMessage { cancellations { cancellationStatus providerBookingItemId ... on Cancellation { incidents { flightNumber } } } } priority extraHeader } } }\",\n \"variables\": {\n \"bookingId\": \"1111111111\",\n \"email\": \"xxxxxx@gmail.com\"\n }\n}" }
Regards,
Abilio_Puente | 2022-02-28 17:01:34 UTC | #5
Hi Jerome, Thx for your reply. Still not working. Additional question, do I need to add the Json header? "headers": {"Accept": "application/json"}
Jerome.Saint-Marc | 2022-02-28 17:05:07 UTC | #6
Hello,
If GraphQL expects such header in a POST request, then yes. I guess that this time, you will have to troubleshoot on GraphQL side. I tried the same request body in a WebServices Data Action (to a dummy API server) and the Data Action could be triggered properly. So I assume that the error you are getting is from GraphQL.
Regards,
Abilio_Puente | 2022-02-28 17:08:29 UTC | #7
I'm getting the error message : Request to backend service failed Status: 406 That's why I thought it may be a header's issue Do I need to whitelist my service somehow?
Jerome.Saint-Marc | 2022-02-28 17:10:18 UTC | #8
If you're enforcing whitelist/IP address check in your Genesys Cloud org, then yes, I think you do have to list it.
Abilio_Puente | 2022-02-28 17:16:46 UTC | #9
I've also got it is a valid Json, so it must be something with that GraphQL end point. Any suggestions? It's the 1st time we work with GraphQL and is not being easy :slight_smile:
Jerome.Saint-Marc | 2022-02-28 17:33:48 UTC | #10
I never worked with GraphQL unfortunately.
You could try to make it work using Postman - if that makes it easier.
Regards,
Abilio_Puente | 2022-03-01 10:23:35 UTC | #11
In postman is working but not in Genesys
Jerome.Saint-Marc | 2022-03-01 14:12:59 UTC | #12
I unfortunately don't have a GraphQL environment so there is nothing much I can say or try.
If you have set all necessary HTTP Headers in your Data Action (i.e. Headers expected by GraphQL), if you are sure about your authentication/authorization setting, you may try to add Transfer-Encoding: buffered header in case it has an impact. If not, I'd suggest to open a ticket with Genesys Cloud Customer Care as we can't investigate customer data/logs from the forum.
Regards,
system | 2022-04-01 14:13:40 UTC | #13
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 13695