Thank you.

The json file I was sending contained the following (which I have tried on 
a single line and also on a single line without spaces)

{
     "add-field":{
               "name":"recordNumber",
               "type":"string",
               "indexed":true,
               "stored":true,
               "docValues":true,
               "omitNorms":true,
               "omitTermFreqAndPositions":true,
               "sortMissingLast":true,
               "multiValued":false
     },
     "add-field":{
               "name":"characterization",
               "type":"text_general",
               "indexed":true,
               "stored":true,
               "omitNorms":true,
               "omitTermFreqAndPositions":true,
               "sortMissingLast":true,
               "multiValued":false
     },
     "add-field":{
               "name":"primaryname",
               "type":"text_general",
               "indexed":true,
               "stored":true,
               "omitNorms":true,
               "omitTermFreqAndPositions":true,
               "sortMissingLast":true,
               "multiValued":false
     },
     "add-field":{
               "name":"originator",
               "type":"text_general",
               "indexed":true,
               "stored":true,
               "omitNorms":true,
               "omitTermFreqAndPositions":true,
               "sortMissingLast":true,
               "multiValued":false
     },
     "add-field":{
               "name":"createdOn",
               "type":"tdate",
               "indexed":true,
               "stored":true,
               "docValues":true,
               "omitNorms":true,
               "omitTermFreqAndPositions":true,
               "multiValued":false
     },
     "add-field":{
               "name":"report",
               "type":"text_en_splitting",
               "indexed":true,
               "stored":true,
               "omitNorms":false,
               "omitTermFreqAndPositions":false,
               "multiValued":false
     }
}


This is the error I was getting

ok: [malpdwfftsla001 -> localhost] => {"changed": false, "content": "{\n 
 \"responseHeader\":{\n    \"status\":0,\n    \"QTime\":0},\n 
 \"errors\":[{\"errorMessages\":\"Error parsing schema operations :The JSON 
must be an Object of the  form {\\\"command\\\": {...},...\"}]}\n", 
"content_length": "185", "content_type": "text/plain;charset=utf-8", 
"redirected": false, "status": 200}



I guess it would have been helpful if I had used wireshark or similar to 
capture what URI was actually POSTing, didn't think to do that at the time.

I tried both with and without the leading space when fetching the json at 
various points.

- name: fetch schema json
  set_fact:
    schema: " {{ lookup('file', 'schema.json')}}"



I tried using vars_files to load the contents but because there are 
multiple "add-field" keys, I only got the last defined "add-field" command. 
 I played with converting to a list of objects and using with_items on the 
uri action (below) but still got the above error for each iteration of the 
list.


- name: add the schema
  uri:
    url: "http://{{ solr_node }}:8983/solr/evaluation/schema"
    method: POST
    body: "{{ item }}"
    body_format: json
    return_content: yes
  with_items:
     schema
  delegate_to: localhost


For now I have abandoned modifying solr via the rest api and am pushing the 
schema files I want to use out directly from ansible.


On Monday, May 9, 2016 at 4:29:28 PM UTC+1, tkuratomi wrote:
>
> uri should work and I can help diagnose that.  What are you sending to it 
> and what's the error message?
>
> -Toshio
>
>
>
> On Fri, May 6, 2016 at 11:10 AM, 'jhawkesworth' via Ansible Development <
> ansibl...@googlegroups.com <javascript:>> wrote:
>
>> Interesting, I'm trying to do something similar with ansible 2.0.0.2 and 
>> looking up the json from a file and then posting it to (a solr instance) 
>> with uri.  
>>
>> The message I'm getting back from solr implies there is something wrong 
>> with the json I'm sending it.
>>
>> Can anybody point me at a working example of this?
>>
>> many thanks
>>
>> Jon
>>
>>
>> On Friday, May 6, 2016 at 2:56:11 PM UTC+1, Brian Coca wrote:
>>>
>>> *sigh* that is new one ... the module is doing a check it shouldn't, we 
>>> need to fix that in the module itself.
>>>
>>>
>>> ----------
>>> Brian Coca
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Development" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to ansible-deve...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to