Created 11-09-2017 10:37 AM
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
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
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
Thanks a lot....it works perfect.