Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

JSON message body for invoke http processor

avatar
New Member

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
New Member

Thanks a lot....it works perfect.