Forum Discussion
HTTP Post
I am trying to create an HTTP Post monitor and i have the following 2 snipits that work:
1:
$url = "http://[pool_mem_ip]:[pool_mem_port]/search";
$options = array(
'http' => array(
'method' => 'POST',
'content' => "{c: '', q: 'hammock', p: '1', l: 'dev', e: 'Production', rj: '1'}" ,
'header'=> "Content-Type: application/json\r\n" .
"Accept: application/json\r\n"
)
);
$context = stream_context_create( $options );
$result = file_get_contents( $url, false, $context );
echo $result;
2:
curl -d "{c: '', q: 'hammock', p: '1', l: 'dev', e: 'Production', rj: '1'}" http://[pool_mem_ip]:[pool_mem_port]/search
However, when I go to setup the monitor, I just get a 500 internal server error. Below is the send string:
POST /search HTTP/1.0\r\nContent-Type: application/json\r\nAccept: application/json\r\n\r\n{c: '', q: 'hammock', p: '1', l: 'dev', e: 'Production', rj: '1'}
I am assuming that I am formatting the send string incorrectly. Any thoughts as to why this post isn't working when the php post works fine? Thanks in advance.
1 Reply
- Kevin_Stewart
Employee
Two thoughts off the top of my head:
-
It's very likely that your Ajax and cURL scripts are auto-injecting the Content-Length header. If you put a -v on your cURL statement, you should see all of the send and receive headers.
-
I don't think this matters as much, but since you're not being explicit in the cURL statement, it's probably inserting an application/x-www-form-urlencoded mime type header. I guess I would check via your -v cURL test to make sure that mime type isn't required.
-
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com