Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
I have to use a GraphQL API in talend but I can't do it.
The goal is to get data from another API with a tjava, then i link the tjava with a tmap and to finish i use the tmap to do a request like : '{"query": "mutation { saveForm(formInput: {wasteDetails{name : ' + row1.wdName + '}) {id,wasteDetails{name}} }" }'
I try 3 differents way.
The first way was with tRest but we can't link a tmap to a tRest
The second way was with a tRestClient but I don't know what put in parameters in my url so I've had a http 500 errors
And the third way was with thttprequest but i don't know how to use the row of my tmap in my file for the post of the thttprequest
I hope I'm clear enough
Thank you in advance
Hello rhall,
sorry for my bad JSON , actually that is my GraphQL mutation statement.
Could you please let me know how to pass it to graphql server through trestclient.
or if there is any alternative way.
Thanks in advance
Your tRestClient has a string and a body input schema. The body column is for XML (document) and the string is for JSON. Send the JSON to the string column using the component before to set it. When formatting the JSON you will need to make sure you handle all of the formatting. Therefore you will need to build it using Java escape characters to escape the quotes.
I have taken your advice and quoted all the strings as shown in the attached pictures,
still getting "post body missing error".
Request you to help us out as it is priority issue to us and we are able to find very less posts on GraphQL - Talend combination.
How is your tFixedFlowOutput configured? Your JSON is still not correct. You are missing a few colons.
the below is mutation statement and i am storing it in a context variable jsonString which is passed to fixedflow
context.jsonString = "\"mutation\"{ \"upsertEntity\"(\"entity\" : { \"name\" : \"ABC1 entity \" }) {\"id\",\"name\"}}";
please let me know how to correct the JSON format.I have minimum knowledge on JSON formation.
Hi rhall,
please help as I stuck here still.
Thanks in advance,
archanalg
Before creating it as a Java String, take the JSON you have created and test it here. This will tell you where it is incorrect. I can see from glancing at it that you are missing semicolons (. For example, your current code is this...
"\"mutation\"{ \"upsertEntity\"(\"entity\" : { \"name\" : \"ABC1 entity \" }) {\"id\",\"name\"}}"
It looks like ":" is missing after "mutation" and "upsertEntry". I'm also not sure that what you are trying to do with the "(" and ")" characters. Can you give a bit more detail on what needs to be provided to the service? Is there any API documentation?
Hello ,
Is there anybody who can help .
Sorry @kakooo16, I have not been on the Community for a while. From what you have said, it looks like you are not sending your JSON query to the string column of the input schema. You will also need to set the tRestClient http method to POST