Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

JSON message body for invoke http processor

avatar
Explorer

How can I make the following http post request using InvokeHttp processor:

$ curl http://xxxxxxxx:8993/solr/demo/update -d ' [ {"url" : "xxxxxxxx", "sharecount" : {"set":10} } ]

I have used a attributesToJson processor which outputs a flowfile in the following format:

{ url:"xxxxxxxxxxxx", sharecount:10 }

1 ACCEPTED SOLUTION

avatar
Master Guru

It looks like the Solr service wants an array of JSON objects but you have a single JSON object, and also it expects the sharecount value to be nested under sharecount in a "set" field. If you know the attributes you need and there aren't very many of them (for example, there are only two you mention), you can use ReplaceText instead of AttributesToJSON, using Expression Language to hand-create the JSON array. The replacement text might look like this:

[{"url": "${url}", "sharecount": {"set": ${sharecount}}}]

View solution in original post

2 REPLIES 2

avatar
Master Guru

It looks like the Solr service wants an array of JSON objects but you have a single JSON object, and also it expects the sharecount value to be nested under sharecount in a "set" field. If you know the attributes you need and there aren't very many of them (for example, there are only two you mention), you can use ReplaceText instead of AttributesToJSON, using Expression Language to hand-create the JSON array. The replacement text might look like this:

[{"url": "${url}", "sharecount": {"set": ${sharecount}}}]

avatar
Explorer

Thanks a lot....it works perfect.