- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
JSON message body for invoke http processor
- Labels:
-
Apache NiFi
-
Apache Solr
Created 11-09-2017 10:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 }
Created 11-09-2017 01:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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}}}]
Created 11-09-2017 01:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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}}}]
Created 11-09-2017 05:15 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot....it works perfect.
