Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
hiba1
Contributor
Contributor

How to use Graphql query with Talend?

Hi Talend Team,

I want to use graphQL query with talend.

I use tRest component. at first, it works.

This is the body:

"{ \"query\": \"query { hotelX { hotels(criteria: { access: \\\"21962\\\", maxSize: 500, hotelCodes: [\\\"\\\"] }, token: \\\"\\\", relay: {}) { token edges { node { code hotelData { hotelCode hotelCodeSupplier hotelName categoryCode rank location { address city zipCode country coordinates { latitude longitude } } medias { code order type updatedAt url texts { text language } } } } } } } }\" }"

The problem is that the token should be dynamic.

it tries this :

"{ \"query\": \"query { hotelX { hotels(criteria: { access: \\\"21962\\\", maxSize: 500, hotelCodes: [\\\"\\\"] }, token: \\\"\\\", relay: {}) { token edges { node { code hotelData { hotelCode hotelCodeSupplier hotelName categoryCode rank location { address city zipCode country coordinates { latitude longitude } } medias { code order type updatedAt url texts { text language } } } } } } } }\" }"

But it returns | Body    | {"data":null,"errors":[{"message":"Expected ',' or '}' after property value in JSON at position 138"}]} |

| ERROR_CODE | 400

Any help please on this .

Thanks in advance

Labels (3)
3 Replies
Anonymous
Not applicable

Hi

I don't see the difference between the first body string and second body string? You want to pass a dynamic token value to the body string?

 

Regards

Shong

hiba1
Contributor
Contributor
Author

Hi @Shicong Hong​ ,

 

You want to pass a dynamic token value to the body string? ==> Yes

 

I try this one but I got an error:

"{ \"query\": \"query { hotelX { hotels(criteria: { access: \\\"21962\\\", maxSize: 500, hotelCodes: [\\\"\\\"] }, token: \\\"\" + (String)globalMap.get(\"token\") + \"\\\", relay: {}) { token edges { node { code hotelData { hotelCode hotelCodeSupplier hotelName categoryCode rank location { address city zipCode country coordinates { latitude longitude } } medias { code order type updatedAt url texts { text language } } } } } } }\" }"

 

anselmopeixoto
Partner - Creator III
Partner - Creator III

Hi @hiba chaieb​ 

 

It seems this json is malformed. Here's some things I've noticed:

 

  1. Its first element is encapsulated between quotes correctly (i.e.: \"query\"), while many other element names aren't.
  2. There are too many escaped backslashes in some places like access: \\\"21962\\\". I suggest you use this instead: \"access\": \"21962\" ...
  3. The String is not closing correctly to concatenate the token stored in globalMap. Try this instead: token: \"" + (String)globalMap.get("token") + "\", ...