Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
kakooo16
Creator
Creator

How to use Graphql query with Talend?

My query is defined :

context.query = ("{\"query\":\"query { psr { product_simples ( merchant_ids: [\"marchent_id\"],product_simple_ids: [\"product_simple\"]) { ean , merchant_product_simple_id,product_simple_id , offers { stock { amount } country { code } status_detail_codes fulfillment_type } } }\n}\"}"

) ;

In Postman am getting the right response but when using talend im getting this error :

|errorCode|errorMessage | |=--------+

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------=|

|400 |{ "title": "Bad Request", "flow_id": "87GqcP1m9KGiNO2A", "detail": "Unexpected token b in JSON at position 58", "contact": "zdirect-tech-support@zalando.de", "

 

code": 400 }|

 

To explain more im passing this "context.query"(String) into a json field (tRESTclient) .

 

My job is as such :

 

0683p000009M9S6.png

 

Greetings .

Labels (2)
1 Solution

Accepted Solutions
kakooo16
Creator
Creator
Author

I've found an easy solution and it's to pass the query in a tREST . 

I'm passing this topic to solved ! .

Thanks

View solution in original post

12 Replies
manodwhb
Champion II
Champion II

If the same payload is working from postman,which is not working on Talend means if you are calling right URL also, then payload is correct which you have passed in Talend. Print the payload in tjava the you can find that is it giving different which you are passing in postman and correct it that way.
kakooo16
Creator
Creator
Author

Hi  manodwhb , it's the same yes . 

I've already print my payload . 

And im getting the error . 

"detail": "Unexpected token b in JSON at position 58",
manodwhb
Champion II
Champion II

When you print in tjava, it is correct means what kind method and HTTP header are you passing correctly?
kakooo16
Creator
Creator
Author

here is my header 0683p000009M9SG.png

 

here is my body

0683p000009M9SL.png

and my tfixedflowinput 

0683p000009M95j.png

manodwhb
Champion II
Champion II

Your configuration looks good and I believe check your Json payload is not correct which is passing in Talend
kakooo16
Creator
Creator
Author

i've verified it many times in  https://jsonformatter.curiousconcept.com/ : 

 

0683p000009M9SQ.png

kakooo16
Creator
Creator
Author

Is there an other way to solve the problem ?
manodwhb
Champion II
Champion II

You have to break it down like you need check while running Talend job,what request has passed to the api check the back-end.
kakooo16
Creator
Creator
Author

How could i do that can you explain more details please ?
Thanks in advance