# WinXP file\_get\_contents with PUT don't work

**URL:** <https://discuss.elastic.co/t/winxp-file-get-contents-with-put-dont-work/3068>\
**Category:** Elasticsearch\
**Created:** [July 6, 2010, 2:09pm UTC](https://discuss.elastic.co/t/winxp-file-get-contents-with-put-dont-work/3068 "2010-07-06T14:09:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chenri](https://avatars.discourse-cdn.com/v4/letter/c/bbe5ce/32.png) [@Chenri](https://discuss.elastic.co/u/Chenri)\
**Post date:** [July 6, 2010, 2:09pm UTC](https://discuss.elastic.co/t/winxp-file-get-contents-with-put-dont-work/3068/1 "2010-07-06T14:09:14Z")

</div>

I'm trying to setup ES in WinXP box using the PHP class from here  
[http://hublog.hubmed.org/archives/001907.html](http://hublog.hubmed.org/archives/001907.html)

For all the method with GET (query , check status, etc) it worked but  
when using PUT (creating index) it produced the following error

===========================  
[http://localhost:9200/putusan/array(1)](http://localhost:9200/putusan/array(1)) { ["method"]=\> string(3)  
"PUT" }  
A PHP Error was encountered

Severity: Warning

Message: file\_get\_contents([http://localhost:9200/putusan/](http://localhost:9200/putusan/))  
[function.file-get-contents]: failed to open stream: HTTP request  
failed! HTTP/1.0 400 Bad Request

Filename: libraries/Elasticsearch.php

# Line Number: 15

What I don't understand is how come the get method worked but not with  
the PUT method  
I've also tried installing curl and run it in command prompt and I got  
the same result  
the GET method for Status and Query worked, but not with the PUT.

Is this something with the ES or just with the PHP or CURL issue?

Anyone can shed some light about this?

---

<div class="post-metadata">

**Author:** ![Chenri](https://avatars.discourse-cdn.com/v4/letter/c/bbe5ce/32.png) [@Chenri](https://discuss.elastic.co/u/Chenri)\
**Post date:** [July 6, 2010, 2:14pm UTC](https://discuss.elastic.co/t/winxp-file-get-contents-with-put-dont-work/3068/2 "2010-07-06T14:14:04Z")

</div>

# Also in the log I found this

[20:39:07,750][DEBUG][action.index] [van Lunt, Cornelius]  
[putusan][3], Node[6202ffed-7ae8-4ad3-85b2-6ccd3c126925], [P],  
S[STARTED]: Failed to execute [[putusan][ma][1],  
source['{keyword:data}']]  
org.elasticsearch.index.mapper.MapperParsingException: Failed to parse  
at  
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:  
333)  
at  
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:  
272)  
at  
org.elasticsearch.index.shard.service.InternalIndexShard.innerIndex(InternalIndexShard.java:  
236)  
at  
org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:  
228)  
at  
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:  
125)  
at  
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:  
56)  
at  
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction  
$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:  
328)  
at  
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction  
$AsyncShardOperationAction.access  
$400(TransportShardReplicationOperationAction.java:198)  
at  
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction  
$AsyncShardOperationAction  
$1.run(TransportShardReplicationOperationAction.java:252)  
at java.util.concurrent.ThreadPoolExecutor  
$Worker.runTask(ThreadPoolExecutor.java:885)  
at java.util.concurrent.ThreadPoolExecutor  
$Worker.run(ThreadPoolExecutor.java:907)  
at java.lang.Thread.run(Thread.java:619)  
Caused by: org.elasticsearch.util.jackson.JsonParseException:  
Unexpected character (''' (code 39)): expected a valid value (number,  
String, array, object, 'true', 'false' or 'null')  
at [Source: [B@b206e9; line: 1, column: 2]  
at  
org.elasticsearch.util.jackson.JsonParser.\_constructError(JsonParser.java:  
943)  
at  
org.elasticsearch.util.jackson.impl.JsonParserBase.\_reportError(JsonParserBase.java:  
632)  
at  
org.elasticsearch.util.jackson.impl.JsonParserBase.\_reportUnexpectedChar(JsonParserBase.java:  
565)  
at  
org.elasticsearch.util.jackson.impl.Utf8StreamParser.\_handleUnexpectedValue(Utf8StreamParser.java:  
1077)  
at  
org.elasticsearch.util.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:  
212)  
at  
org.elasticsearch.util.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:  
46)  
at  
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:  
289)  
... 11 more

On Jul 6, 9:09 pm, Chenri [chenrij...@gmail.com](mailto:chenrij...@gmail.com) wrote:

> I'm trying to setup ES in WinXP box using the PHP class from herehttp://hublog.hubmed.org/archives/001907.html
> 
> For all the method with GET (query , check status, etc) it worked but  
> when using PUT (creating index) it produced the following error
> 
> ===========================[http://localhost:9200/putusan/array(1)](http://localhost:9200/putusan/array(1)) { ["method"]=\> string(3)  
> "PUT" }  
> A PHP Error was encountered
> 
> Severity: Warning
> 
> Message: file\_get\_contents([http://localhost:9200/putusan/](http://localhost:9200/putusan/))  
> [function.file-get-contents]: failed to open stream: HTTP request  
> failed! HTTP/1.0 400 Bad Request
> 
> Filename: libraries/Elasticsearch.php
> 
> # Line Number: 15
> 
> What I don't understand is how come the get method worked but not with  
> the PUT method  
> I've also tried installing curl and run it in command prompt and I got  
> the same result  
> the GET method for Status and Query worked, but not with the PUT.
> 
> Is this something with the ES or just with the PHP or CURL issue?
> 
> Anyone can shed some light about this?

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [July 6, 2010, 2:16pm UTC](https://discuss.elastic.co/t/winxp-file-get-contents-with-put-dont-work/3068/3 "2010-07-06T14:16:29Z")

</div>

Can you provide the actual PUT request that you used?

It is likely that the syntax is wrong.

ta

clint

On Tue, 2010-07-06 at 07:14 -0700, Chenri wrote:

> # Also in the log I found this
> 
> [20:39:07,750][DEBUG][action.index] [van Lunt, Cornelius]  
> [putusan][3], Node[6202ffed-7ae8-4ad3-85b2-6ccd3c126925], [P],  
> S[STARTED]: Failed to execute [[putusan][ma][1],  
> source['{keyword:data}']]  
> org.elasticsearch.index.mapper.MapperParsingException: Failed to parse  
> at  
> org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:  
> 333)  
> at  
> org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:  
> 272)  
> at  
> org.elasticsearch.index.shard.service.InternalIndexShard.innerIndex(InternalIndexShard.java:  
> 236)  
> at  
> org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:  
> 228)  
> at  
> org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:  
> 125)  
> at  
> org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:  
> 56)  
> at  
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction  
> $AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:  
> 328)  
> at  
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction  
> $AsyncShardOperationAction.access  
> $400(TransportShardReplicationOperationAction.java:198)  
> at  
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction  
> $AsyncShardOperationAction  
> $1.run(TransportShardReplicationOperationAction.java:252)  
> at java.util.concurrent.ThreadPoolExecutor  
> $Worker.runTask(ThreadPoolExecutor.java:885)  
> at java.util.concurrent.ThreadPoolExecutor  
> $Worker.run(ThreadPoolExecutor.java:907)  
> at java.lang.Thread.run(Thread.java:619)  
> Caused by: org.elasticsearch.util.jackson.JsonParseException:  
> Unexpected character (''' (code 39)): expected a valid value (number,  
> String, array, object, 'true', 'false' or 'null')  
> at [Source: [B@b206e9; line: 1, column: 2]  
> at  
> org.elasticsearch.util.jackson.JsonParser.\_constructError(JsonParser.java:  
> 943)  
> at  
> org.elasticsearch.util.jackson.impl.JsonParserBase.\_reportError(JsonParserBase.java:  
> 632)  
> at  
> org.elasticsearch.util.jackson.impl.JsonParserBase.\_reportUnexpectedChar(JsonParserBase.java:  
> 565)  
> at  
> org.elasticsearch.util.jackson.impl.Utf8StreamParser.\_handleUnexpectedValue(Utf8StreamParser.java:  
> 1077)  
> at  
> org.elasticsearch.util.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:  
> 212)  
> at  
> org.elasticsearch.util.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:  
> 46)  
> at  
> org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:  
> 289)  
> ... 11 more
> 
> On Jul 6, 9:09 pm, Chenri [chenrij...@gmail.com](mailto:chenrij...@gmail.com) wrote:
> 
> > I'm trying to setup ES in WinXP box using the PHP class from herehttp://hublog.hubmed.org/archives/001907.html
> > 
> > For all the method with GET (query , check status, etc) it worked but  
> > when using PUT (creating index) it produced the following error
> > 
> > ===========================[http://localhost:9200/putusan/array(1)](http://localhost:9200/putusan/array(1)) { ["method"]=\> string(3)  
> > "PUT" }  
> > A PHP Error was encountered
> > 
> > Severity: Warning
> > 
> > Message: file\_get\_contents([http://localhost:9200/putusan/](http://localhost:9200/putusan/))  
> > [function.file-get-contents]: failed to open stream: HTTP request  
> > failed! HTTP/1.0 400 Bad Request
> > 
> > Filename: libraries/Elasticsearch.php
> > 
> > # Line Number: 15
> > 
> > What I don't understand is how come the get method worked but not with  
> > the PUT method  
> > I've also tried installing curl and run it in command prompt and I got  
> > the same result  
> > the GET method for Status and Query worked, but not with the PUT.
> > 
> > Is this something with the ES or just with the PHP or CURL issue?
> > 
> > Anyone can shed some light about this?  
> > --  
> > Web Announcements Limited is a company registered in England and Wales,  
> > with company number 05608868, with registered address at 10 Arvon Road,  
> > London, N5 1PR.

---

<div class="post-metadata">

**Author:** ![Chenri](https://avatars.discourse-cdn.com/v4/letter/c/bbe5ce/32.png) [@Chenri](https://discuss.elastic.co/u/Chenri)\
**Post date:** [July 6, 2010, 2:39pm UTC](https://discuss.elastic.co/t/winxp-file-get-contents-with-put-dont-work/3068/4 "2010-07-06T14:39:13Z")

</div>

$data='{"keyword":"halo"}';  
$elasticsearch-\>add($id,$data);

- 
- 

below are the format echoed from the php ES class code

file\_get\_contents(  
[http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b](http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b), NULL,  
stream\_context\_create(array('http' =\> _Array_))))

where the \*Array \*contains  
array(2) { ["method"]=\> string(3) "_PUT_" ["content"]=\> string(18)  
"{"keyword":"halo"}" }

On Tue, Jul 6, 2010 at 9:16 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:

> Can you provide the actual PUT request that you used?
> 
> It is likely that the syntax is wrong.
> 
> ta
> 
> clint
> 
> On Tue, 2010-07-06 at 07:14 -0700, Chenri wrote:
> 
> > # Also in the log I found this
> > 
> > [20:39:07,750][DEBUG][action.index] [van Lunt, Cornelius]  
> > [putusan][3], Node[6202ffed-7ae8-4ad3-85b2-6ccd3c126925], [P],  
> > S[STARTED]: Failed to execute [[putusan][ma][1],  
> > source['{keyword:data}']]  
> > org.elasticsearch.index.mapper.MapperParsingException: Failed to parse  
> > at
> 
> org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:
> 
> > 1. at
> 
> org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:
> 
> > 1. at
> 
> org.elasticsearch.index.shard.service.InternalIndexShard.innerIndex(InternalIndexShard.java:
> 
> > 1. at
> 
> org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:
> 
> > 1. at
> 
> org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:
> 
> > 1. at
> 
> org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:
> 
> > 1. at
> 
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
> 
> > 
> 
> $AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:
> 
> > 1. at
> 
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
> 
> > $AsyncShardOperationAction.access  
> > $400(TransportShardReplicationOperationAction.java:198)  
> > at
> 
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
> 
> > $AsyncShardOperationAction  
> > $1.run(TransportShardReplicationOperationAction.java:252)  
> > at java.util.concurrent.ThreadPoolExecutor  
> > $Worker.runTask(ThreadPoolExecutor.java:885)  
> > at java.util.concurrent.ThreadPoolExecutor  
> > $Worker.run(ThreadPoolExecutor.java:907)  
> > at java.lang.Thread.run(Thread.java:619)  
> > Caused by: org.elasticsearch.util.jackson.JsonParseException:  
> > Unexpected character (''' (code 39)): expected a valid value (number,  
> > String, array, object, 'true', 'false' or 'null')  
> > at [Source: [B@b206e9; line: 1, column: 2]  
> > at
> 
> org.elasticsearch.util.jackson.JsonParser.\_constructError(JsonParser.java:
> 
> > 1. at
> 
> org.elasticsearch.util.jackson.impl.JsonParserBase.\_reportError(JsonParserBase.java:
> 
> > 1. at
> 
> org.elasticsearch.util.jackson.impl.JsonParserBase.\_reportUnexpectedChar(JsonParserBase.java:
> 
> > 1. at
> 
> org.elasticsearch.util.jackson.impl.Utf8StreamParser.\_handleUnexpectedValue(Utf8StreamParser.java:
> 
> > 1. at
> 
> org.elasticsearch.util.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:
> 
> > 1. at
> 
> org.elasticsearch.util.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:
> 
> > 1. at
> 
> org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:
> 
> > 1. ... 11 more
> > 
> > On Jul 6, 9:09 pm, Chenri [chenrij...@gmail.com](mailto:chenrij...@gmail.com) wrote:
> > 
> > > I'm trying to setup ES in WinXP box using the PHP class from  
> > > herehttp://hublog.hubmed.org/archives/001907.html
> > > 
> > > For all the method with GET (query , check status, etc) it worked but  
> > > when using PUT (creating index) it produced the following error
> > > 
> > > ===========================[http://localhost:9200/putusan/array(1)](http://localhost:9200/putusan/array(1)) {  
> > > ["method"]=\> string(3)  
> > > "PUT" }  
> > > A PHP Error was encountered
> > > 
> > > Severity: Warning
> > > 
> > > Message: file\_get\_contents([http://localhost:9200/putusan/](http://localhost:9200/putusan/))  
> > > [function.file-get-contents]: failed to open stream: HTTP request  
> > > failed! HTTP/1.0 400 Bad Request
> > > 
> > > Filename: libraries/Elasticsearch.php
> > > 
> > > # Line Number: 15
> > > 
> > > What I don't understand is how come the get method worked but not with  
> > > the PUT method  
> > > I've also tried installing curl and run it in command prompt and I got  
> > > the same result  
> > > the GET method for Status and Query worked, but not with the PUT.
> > > 
> > > Is this something with the ES or just with the PHP or CURL issue?
> > > 
> > > Anyone can shed some light about this?  
> > > --  
> > > Web Announcements Limited is a company registered in England and Wales,  
> > > with company number 05608868, with registered address at 10 Arvon Road,  
> > > London, N5 1PR.

--  
Chenri J  
Mutiara Taman Palem H2-3  
Mobile Phone: (62) (813) 152 05 949

> **[NotSolution.com is for sale | HugeDomains](https://www.hugedomains.com/domain_profile.cfm?d=notsolution.com)**
>
> Easy, affordable options for you to obtain the domain you want. Safe and secure shopping.

---

<div class="post-metadata">

**Author:** ![Chenri](https://avatars.discourse-cdn.com/v4/letter/c/bbe5ce/32.png) [@Chenri](https://discuss.elastic.co/u/Chenri)\
**Post date:** [July 6, 2010, 2:44pm UTC](https://discuss.elastic.co/t/winxp-file-get-contents-with-put-dont-work/3068/5 "2010-07-06T14:44:39Z")

</div>

I've also tried to changed the  
$data ="halo";

this also create the same error

On Tue, Jul 6, 2010 at 9:39 PM, Chenri [chenrijano@gmail.com](mailto:chenrijano@gmail.com) wrote:

> $data='{"keyword":"halo"}';  
> $elasticsearch-\>add($id,$data);
> 
> - 
> - 
> 
> below are the format echoed from the php ES class code
> 
> file\_get\_contents(  
> [http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b](http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b), NULL,  
> stream\_context\_create(array('http' =\> _Array_))))
> 
> where the \*Array \*contains  
> array(2) { ["method"]=\> string(3) "_PUT_" ["content"]=\> string(18)  
> "{"keyword":"halo"}" }
> 
> On Tue, Jul 6, 2010 at 9:16 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:
> 
> > Can you provide the actual PUT request that you used?
> > 
> > It is likely that the syntax is wrong.
> > 
> > ta
> > 
> > clint
> > 
> > On Tue, 2010-07-06 at 07:14 -0700, Chenri wrote:
> > 
> > > # Also in the log I found this
> > > 
> > > [20:39:07,750][DEBUG][action.index] [van Lunt, Cornelius]  
> > > [putusan][3], Node[6202ffed-7ae8-4ad3-85b2-6ccd3c126925], [P],  
> > > S[STARTED]: Failed to execute [[putusan][ma][1],  
> > > source['{keyword:data}']]  
> > > org.elasticsearch.index.mapper.MapperParsingException: Failed to parse  
> > > at
> > 
> > org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:
> > 
> > > 1. at
> > 
> > org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:
> > 
> > > 1. at
> > 
> > org.elasticsearch.index.shard.service.InternalIndexShard.innerIndex(InternalIndexShard.java:
> > 
> > > 1. at
> > 
> > org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:
> > 
> > > 1. at
> > 
> > org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:
> > 
> > > 1. at
> > 
> > org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:
> > 
> > > 1. at
> > 
> > org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
> > 
> > > 
> > 
> > $AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:
> > 
> > > 1. at
> > 
> > org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
> > 
> > > $AsyncShardOperationAction.access  
> > > $400(TransportShardReplicationOperationAction.java:198)  
> > > at
> > 
> > org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
> > 
> > > $AsyncShardOperationAction  
> > > $1.run(TransportShardReplicationOperationAction.java:252)  
> > > at java.util.concurrent.ThreadPoolExecutor  
> > > $Worker.runTask(ThreadPoolExecutor.java:885)  
> > > at java.util.concurrent.ThreadPoolExecutor  
> > > $Worker.run(ThreadPoolExecutor.java:907)  
> > > at java.lang.Thread.run(Thread.java:619)  
> > > Caused by: org.elasticsearch.util.jackson.JsonParseException:  
> > > Unexpected character (''' (code 39)): expected a valid value (number,  
> > > String, array, object, 'true', 'false' or 'null')  
> > > at [Source: [B@b206e9; line: 1, column: 2]  
> > > at
> > 
> > org.elasticsearch.util.jackson.JsonParser.\_constructError(JsonParser.java:
> > 
> > > 1. at
> > 
> > org.elasticsearch.util.jackson.impl.JsonParserBase.\_reportError(JsonParserBase.java:
> > 
> > > 1. at
> > 
> > org.elasticsearch.util.jackson.impl.JsonParserBase.\_reportUnexpectedChar(JsonParserBase.java:
> > 
> > > 1. at
> > 
> > org.elasticsearch.util.jackson.impl.Utf8StreamParser.\_handleUnexpectedValue(Utf8StreamParser.java:
> > 
> > > 1. at
> > 
> > org.elasticsearch.util.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:
> > 
> > > 1. at
> > 
> > org.elasticsearch.util.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:
> > 
> > > 1. at
> > 
> > org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:
> > 
> > > 1. ... 11 more
> > > 
> > > On Jul 6, 9:09 pm, Chenri [chenrij...@gmail.com](mailto:chenrij...@gmail.com) wrote:
> > > 
> > > > I'm trying to setup ES in WinXP box using the PHP class from  
> > > > herehttp://hublog.hubmed.org/archives/001907.html
> > > > 
> > > > For all the method with GET (query , check status, etc) it worked but  
> > > > when using PUT (creating index) it produced the following error
> > > > 
> > > > ===========================[http://localhost:9200/putusan/array(1)](http://localhost:9200/putusan/array(1)) {  
> > > > ["method"]=\> string(3)  
> > > > "PUT" }  
> > > > A PHP Error was encountered
> > > > 
> > > > Severity: Warning
> > > > 
> > > > Message: file\_get\_contents([http://localhost:9200/putusan/](http://localhost:9200/putusan/))  
> > > > [function.file-get-contents]: failed to open stream: HTTP request  
> > > > failed! HTTP/1.0 400 Bad Request
> > > > 
> > > > Filename: libraries/Elasticsearch.php
> > > > 
> > > > # Line Number: 15
> > > > 
> > > > What I don't understand is how come the get method worked but not with  
> > > > the PUT method  
> > > > I've also tried installing curl and run it in command prompt and I got  
> > > > the same result  
> > > > the GET method for Status and Query worked, but not with the PUT.
> > > > 
> > > > Is this something with the ES or just with the PHP or CURL issue?
> > > > 
> > > > Anyone can shed some light about this?  
> > > > --  
> > > > Web Announcements Limited is a company registered in England and Wales,  
> > > > with company number 05608868, with registered address at 10 Arvon Road,  
> > > > London, N5 1PR.
> 
> --  
> Chenri J  
> Mutiara Taman Palem H2-3  
> Mobile Phone: (62) (813) 152 05 949  
> [NOTsolution.com](http://NOTsolution.com)

--  
Chenri J  
Mutiara Taman Palem H2-3  
Mobile Phone: (62) (813) 152 05 949

> **[NotSolution.com is for sale | HugeDomains](https://www.hugedomains.com/domain_profile.cfm?d=notsolution.com)**
>
> Easy, affordable options for you to obtain the domain you want. Safe and secure shopping.

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [July 6, 2010, 2:53pm UTC](https://discuss.elastic.co/t/winxp-file-get-contents-with-put-dont-work/3068/6 "2010-07-06T14:53:47Z")

</div>

> On Tue, Jul 6, 2010 at 9:39 PM, Chenri [chenrijano@gmail.com](mailto:chenrijano@gmail.com) wrote:  
> $data='{"keyword":"halo"}';  
> $elasticsearch-\>add($id,$data);
> 
> ```
> below are the format echoed from the php ES class code 
> file_get_contents(http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b, NULL, stream_context_create(array('http' => Array))))
>     
>     
> where the Array contains
> array(2) { ["method"]=> string(3) "PUT" ["content"]=>
> string(18) "{"keyword":"halo"}" }
> 
> ```

The equivalent using curl on the command line (at least in Unix - can't  
speak for Windows) would be:

curl -XPUT '[http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b](http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b)' -d '  
{  
"keywords" : "halo"  
}  
'

Does that work?

Looking at your error message:

> ```
> > Caused by:
> org.elasticsearch.util.jackson.JsonParseException:
> > Unexpected character (''' (code 39)): expected a
> valid value (number,
> > String, array, object, 'true', 'false' or 'null')
> > at [Source: [B@b206e9; line: 1, column: 2]
> > at
> >
> 
> ```

your JSON is malformed.

clint

---

<div class="post-metadata">

**Author:** ![Chenri](https://avatars.discourse-cdn.com/v4/letter/c/bbe5ce/32.png) [@Chenri](https://discuss.elastic.co/u/Chenri)\
**Post date:** [July 6, 2010, 5:59pm UTC](https://discuss.elastic.co/t/winxp-file-get-contents-with-put-dont-work/3068/7 "2010-07-06T17:59:03Z")

</div>

After trying to port the class using curl in PHP  
and succeed in several method but failure in others  
I've decided that I'll go for the linux environment.

Anyway thanks for the help Clint

On Tue, Jul 6, 2010 at 9:53 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:

> > On Tue, Jul 6, 2010 at 9:39 PM, Chenri [chenrijano@gmail.com](mailto:chenrijano@gmail.com) wrote:  
> > $data='{"keyword":"halo"}';  
> > $elasticsearch-\>add($id,$data);
> > 
> > ```
> > below are the format echoed from the php ES class code
> > file_get_contents(
> > 
> > ```
> 
> [http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b](http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b), NULL,  
> stream\_context\_create(array('http' =\> Array))))
> 
> > ```
> > where the Array contains
> > array(2) { ["method"]=> string(3) "PUT" ["content"]=>
> > string(18) "{"keyword":"halo"}" }
> > 
> > ```
> 
> The equivalent using curl on the command line (at least in Unix - can't  
> speak for Windows) would be:
> 
> curl -XPUT '  
> [http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b](http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b)' -d '  
> {  
> "keywords" : "halo"  
> }  
> '
> 
> Does that work?
> 
> Looking at your error message:
> 
> > ```
> > > Caused by:
> > org.elasticsearch.util.jackson.JsonParseException:
> > > Unexpected character (''' (code 39)): expected a
> > valid value (number,
> > > String, array, object, 'true', 'false' or 'null')
> > > at [Source: [B@b206e9; line: 1, column: 2]
> > > at
> > >
> > 
> > ```
> 
> your JSON is malformed.
> 
> clint

--  
Chenri J  
Mutiara Taman Palem H2-3  
Mobile Phone: (62) (813) 152 05 949

> **[NotSolution.com is for sale | HugeDomains](https://www.hugedomains.com/domain_profile.cfm?d=notsolution.com)**
>
> Easy, affordable options for you to obtain the domain you want. Safe and secure shopping.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:22am UTC](https://discuss.elastic.co/t/winxp-file-get-contents-with-put-dont-work/3068/8 "2017-07-06T04:22:40Z")

</div>


