I am getting a 500 when requesting the following right now :
curl --head https://api.infusionsoft.com/crm/rest/v1/transactions/nnnn?access_token=xxxx
HTTP/1.1 500
Date: Fri, 04 Feb 2022 18:27:27 GMT
Content-Type: application/json;charset=UTF-8
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache, no-store
Expires: Fri, 04 Feb 2022 18:27:27 GMT
Set-Cookie: JSESSIONID=xxxxx; Path=/; Secure; HttpOnly
X-FRAME-OPTIONS: DENY
Strict-Transport-Security: max-age=31536000;includeSubDomains
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-store
vary: accept-encoding
Content-Language: en-US
Via: 1.1 google
CF-Cache-Status: DYNAMIC
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Set-Cookie: GCLB=CMrImuTym-6xNQ; path=/; HttpOnly; expires=Sat, 05-Feb-2022 06:27:27 GMT
Set-Cookie: __cf_bm=xxxxxx-xxxx-0-xxx/D/S5x/xxxxx/xxxxx=; path=/; expires=Fri, 04-Feb-22 18:57:27 GMT; domain=.infusionsoft.com; HttpOnly; Secure; SameSite=None
Server: cloudflare
CF-RAY: xxxx-SEA
But chat support says that the API server is not down. I cross-checked with the curl command on the server too. Same response - 500.
TomScott
(Tom Scott)
February 4, 2022, 7:20pm
2
Good afternoon Dave,
A 500 usually indicates there is some kind of problem processing the record for display; please file a support ticket here to have our Advanced Support team look at the specific data for the record in question.
https://developer.infusionsoft.com/support/tickets/create/
Additionally, you shouldn’t pass access_token as a query parameter, and it is not a supported operation so we don’t guarantee that it will function in that manner in the future. The proper method is to pass it as an “Authorization” header as “Bearer {token}”.
https://developer.keap.com/getting-started-oauth-keys/
The API is returning 200 now with the correct customer data - no change was done at my end.
You mean to say as in the header of the request ? So I have to switch to using cURL instead of file_get_contents
?
$url = "https://api.infusionsoft.com/crm/rest/v1/transactions/{$transaction_id}?access_token={$token}";
$data_transactions = file_get_contents($url);
To this ?
$url = "https://api.infusionsoft.com/crm/rest/v1/transactions/{$transaction_id}";
$authorization = "Authorization: Bearer {$token}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json' , $authorization ));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$response = curl_exec($ch);
curl_close($ch);
$json_transactions = json_decode($response);
TomScott
(Tom Scott)
February 7, 2022, 4:42pm
4
I’m not a PHP guy, but it looks like you can set the Headers in an object, open the stream and pass it to that method:
// Create a stream
$opts = [
"http" => [
"method" => "GET",
"header" => "Authorization: Bearer {bearerToken}\r\n" .
"SomeOtherHeader: foobar\r\n"
]
];
// DOCS: https://www.php.net/manual/en/function.stream-context-create.php
$context = stream_context_create($opts);
// Open the file using the HTTP headers set above
// DOCS: https://www.php.net/manual/en/function.file-get-contents.php
$file = file_get_contents('http://www.example.com/', false, $context);