GET /post-order/v2/casemanagement/{caseId} call of eBay Post Order API giving an empty string. Can anyone clear out where does my code go wrong? Am I passing the headers correctly? Especially is the syntax of authorization correct?
<?php
error_reporting(E_ALL); // Turn on all errors, warnings and notices for easier debugging
//Seller Authorization Token
$userAuthToken= 'Authorization:TOKEN abc123';
//Endpoint URL to Use
$url = "https://api.ebay.com/post-order/v2/casemanagement/xyz";
//Initializle cURL
$connection = curl_init();
//Set Endpoint URL
curl_setopt($connection,CURLOPT_URL,$url);
//Set HTTP Method
curl_setopt($connection, CURLOPT_HTTPGET, true);
//Create Array of Required Headers
$headers = array();
$headers[] = $userAuthToken;
$headers[] = 'Content-Type:application/json';
$headers[] = 'X-EBAY-C-MARKETPLACE-ID:EBAY-DE';
//var_dump($headers);
//set the headers using the array of headers
curl_setopt($connection,CURLOPT_HTTPHEADER,$headers);
//set it to return the transfer as a string from curl_exec
curl_setopt($connection,CURLOPT_RETURNTRANSFER,1);
//stop CURL from verifying the peer's certificate
curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
//Execute the Request
$response = curl_exec($connection);
//close the connection
curl_close($connection);
var_dump($response);
2
Answers
ADD
curl_setopt($connection, CURLOPT_HEADER, 1);
To return the headers and see what your problem might be.
I also don’t know if it matters but my headers array looks like:
$headers = array (
'Authorization: ' . "TOKEN $token",
'Content-Type: ' . 'application/json',
'X-EBAY-C-MARKETPLACE-ID: ' . 'EBAY-US',
'Accept: ' . 'application/json',
);
So you can see there is a space after the colon.
Try this code it is working fine for me.
Response: