Created 09-29-2023 11:53 AM
Hello,
I am trying to get an key from GetMongo Processor and then I am trying to replace the value in the format
key=value
using ReplaceText where value here is the result which I am getting and then passing to different POST API which supports `application/x-www-form-urlencoded`
From GetMongo Processor I am getting value {match_id: 789456}
and In replaceText Processor I am using in Search Value : (?s)(^.*$) and Replacement Value in match_id=${match_id:urlEncode()}
But in API data is getting passed as { match_id: '' } though it should pass as { match_id: 789456 }
What I am doing wrong in ReplaceText Processor
Can you please help me out with this ?
Created 10-01-2023 01:03 PM
Change the setting of the EvaluateJsonPath "Destination" Property to flowfile-attribute instead of flowfile-content. Setting this property with the later value will change the whole flowfile content and wont create the attribute you are looking for in the replacetext processor. if that still doesnt work, make sure to check after the EvaluateJsonPath to see if the "match_id" attribute was created and populated with the correct value, if not then I need to see the response from the GetMongo processor to make sure the correct path is being set in the EvaluateJsonPath.
Created 09-29-2023 12:53 PM
@piyush7829 Welcome to the Cloudera Community!
To help you get the best possible solution, I have tagged our NiFi experts @SAMSAL @MattWho who may be able to assist you further.
Please keep us updated on your post, and we hope you find a satisfactory solution to your query.
Regards,
Diana Torres,Created 09-30-2023 07:24 AM
Hi @piyush7829 ,
I'm assuming you are getting the json {"match_id": 789456} response from the GetMongo processor, after this you are directly using ReplaceText processor with the replace value:
match_id=${match_id:urlEncode()}
This replace value is using flowfile attribute ${match_id}, but I dont see in your flow where this attribute is defined! I think you are missing a step to extract this attribute between GetMongo & ReplaceText processors. If the response is Json then you can use EvaluateJsonPath processor to extract the match_id attribute :
After you connect the "match" rel from the above processor to the ReplaceText processor , the replacement value should work.
If that helps please accept solution.
Thanks
Created 10-01-2023 12:50 PM
hello @SAMSAL ,
Thanks for your reply. I have tried what you suggested. And even i tried that before but I am still getting same issue. Please find screenshots
I am still getting { match_id: '' }
Created 10-01-2023 01:03 PM
Change the setting of the EvaluateJsonPath "Destination" Property to flowfile-attribute instead of flowfile-content. Setting this property with the later value will change the whole flowfile content and wont create the attribute you are looking for in the replacetext processor. if that still doesnt work, make sure to check after the EvaluateJsonPath to see if the "match_id" attribute was created and populated with the correct value, if not then I need to see the response from the GetMongo processor to make sure the correct path is being set in the EvaluateJsonPath.