Status code 201 http response 'location' header with curl php

16 Views Asked by At

I am using an api which works but I am having trouble with the location header. The api document states - If a 201 response is returned it means successful and the location of the newly created data in the http response 'location' header.

So I get the 201 response but no data. I assume the data is in the location header how to get that data.

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $api_url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    $result = curl_exec($ch);
0

There are 0 best solutions below