Hello Josep,
you need to send the data as json, not as urlencoded, so:
values = { "doc" : "{ Parametros : PruebaParametros }" }
postData = json.dumps(values)
req = urllib2.Request(query, postData)
response = urllib2.urlopen(req)
but unless you have very specific requirements I'd strongly suggest
you use the official python client - http://elasticsearch-py.rtfd.org
Hope this helps,
Honza
On Tue, Apr 8, 2014 at 2:11 AM, Josep Floriach Ventosinos
<[email protected]> wrote:
> Hi everyone,
>
> I'm trying to do a simple update. With curl simply I put following command
> in console.
>
> curl -XPOST
> http://localhost:9200/peticiones-2014.04.08/logs/pJ_T-Lt1QW6u3luxVrI_ZQ/_update
> -d '{"doc": { "Parametros" : "PruebaParametros"}}'{'doc': '{ Parametros :
> PruebaParametros}'}
>
> And it works perfectly. The problem is that I want do exactly the same thing
> in a script, with urllib2 in Python. My code is:
>
> values = { "doc" : "{ Parametros : PruebaParametros }" }
> postData = urllib.urlencode(values)
> req = urllib2.Request(query, postData)
> response = urllib2.urlopen(req)
>
> Query is
> "http://localhost:9200/peticiones-2014.04.08/logs/pJ_T-Lt1QW6u3luxVrI_ZQ/_update".
> But I'm getting the following error: "urllib2.HTTPError: HTTP Error 500:
> Internal Server Error"
>
> What am I doing wrong?
>
> --
> You received this message because you are subscribed to the Google Groups
> "elasticsearch" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/00c788f1-ebac-4904-a12d-1db32fd47c85%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CABfdDio4_BSFi-Hf5AQ_-iMhkLRQq-jzvqXX7iiPLVaZcp249A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.