Created 12-06-2023 04:40 AM
I'm encountering challenges when using the InvokeHTTP processor in Apache NiFi to send GraphQL POST requests. Specifically, I'm trying to execute GraphQL mutations via POST but facing difficulties in configuring the InvokeHTTP processor to handle these requests properly.
Problem:
I've set up an InvokeHTTP processor to send GraphQL mutation requests via POST to a specific endpoint. However, the requests don't seem to be reaching the GraphQL server as expected.
Details:
The InvokeHTTP processor is configured with the following properties:
The body content is constructed in JSON format as required by the GraphQL server. It includes the mutation query and variables.
Request for Help:
I'm seeking guidance on how to properly configure the InvokeHTTP processor in NiFi to successfully send GraphQL POST requests. If anyone has experience using InvokeHTTP for GraphQL mutations or suggestions for troubleshooting this issue, I would greatly appreciate your insights.
QUERY: {
"query": "mutation AddUser($input: [AddUserInput!]!, $upsert: Boolean) { addUser(input: $input, upsert: $upsert) { user { name } } }",
"variables": {
"input": [
{
"name": "Ali",
"username": "Ali",
"phone1": "111222333",
"address": "LAHORE"
}
],
"upsert": false
}
}
Created 12-07-2023 01:39 AM
@steven-matison Thank you for responding..!
By using
Created 12-07-2023 04:50 AM
@Fayza Nice work. If you can, you should try to remove ReplaceText. You should be able to get the payload exactly how you want it in text input box for GenerateFlowFile.
Created on 12-06-2023 05:15 AM - edited 12-06-2023 05:16 AM
@Fayza Without seeing any error it is impossible for us to solve a specific problem. That said, I have some suggestions.
1. Always make sure you have a working api call. For example: Use Postman. You need to 100% know the call is working, auth, headers, proper format, proper payload, etc. This also makes sure the receiving end is open (networking, firewall, etc).
2. Test invokteHTTP without routing fail,retry,no-retry back to the processor. I use an output port for everything other than response. In testing, you need to know what happened. Inspect flowfile attributes inside of fail,retry, no-retry, to get more details. When i know my flow works, i may auto terminate, or re-route failure back to processor again, but NOT during testing/creation of the flow.
3. Last but not least, make sure that nifi host(s) are able to reach the endpoint. I suspect this is the issue you are bumping into.
If you get invokeHttp talking to the endpoint, you should be seeing more details as to what if any errors are in the mutation payload.
Created 12-06-2023 05:30 AM
Hey @steven-matison Thank you for responding.
I have defined the Body Content:
Can you provide me any information in the form of article of any other sources where I can find the POST data of GraphQL. So, that It will help full for me.
Actually, I have CURL command which is in working state. I try it too. Data from POSTMAN has been sending but as I define the Method and URL in the InvokedHTTP processor. Can you tell me where I can manage my post request data???
Thank you again
Created on 12-06-2023 05:32 AM - edited 12-06-2023 05:33 AM
Created 12-06-2023 05:42 AM
You need to send a flowfile to InvokeHttp that has the content you want. Make this flow to test: GenerateFlowfile (body of flowfile is the JSON payload), route to InvokeHttp. Your post headers are added to InvokeHttp in similar manner as to how you did "Body Content".
Created 12-07-2023 01:39 AM
@steven-matison Thank you for responding..!
By using
Created 12-07-2023 04:50 AM
@Fayza Nice work. If you can, you should try to remove ReplaceText. You should be able to get the payload exactly how you want it in text input box for GenerateFlowFile.