For a deeper look into our World Check One API, look into:

Overview |  Quickstart |  Documentation |  Downloads

question

Upvotes
Accepted
31 1 2 2

GET cases/{caseSystemId} works in postman, always returns 401 in php

I am trying to get a simple get request to work in php, that I've accomplished with postman without issue.

In postman, the outputted http code is the following:

GET /v1/cases/0a599156-6eb7-1e40-9bb3-2aae00039721 HTTP/1.1
Host: rms-world-check-one-api-pilot.thomsonreuters.com
Date: Fri, 06 Dec 2019 16:22:22 GMT
Authorization: Signature keyId="0b8f7e24-16d0-4672-9234-9b07b84d90d3",algorithm="hmac-sha256",headers="(request-target) host date",signature="N48t26VhJFS9KQZOqqIRumanWxfZEWwzJcRDF76f07c="
User-Agent: PostmanRuntime/7.19.0
Accept: */*
Cache-Control: no-cache
Postman-Token: d193cb45-f40d-4231-ad73-a203f00357b9,be6e8a64-807b-4184-88d3-fb1a0772b282
Host: rms-world-check-one-api-pilot.thomsonreuters.com
Accept-Encoding: gzip, deflate
Connection: keep-alive
cache-control: no-cache

And I get the information of the case back successfully.



my php code is as follows:

$curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://rms-world-check-one-api-pilot.thomsonreuters.com/v1/cases/0a599156-6eb7-1e40-9bb3-2aae00039721",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_POSTFIELDS => "",
      CURLOPT_HTTPHEADER => array(
        "Accept: */*",
        "Accept-Encoding: gzip, deflate",
        "Authorization: Signature keyId=\"0b8f7e24-16d0-4672-9234-9b07b84d90d3\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date\",signature=\"N48t26VhJFS9KQZOqqIRumanWxfZEWwzJcRDF76f07c=\"",
        "Cache-Control: no-cache",
        "Connection: keep-alive",
        "Date: Fri, 06 Dec 2019 16:22:22 GMT",
        "Host: rms-world-check-one-api-pilot.thomsonreuters.com",
        "cache-control: no-cache"
      ),
    ));

    $response = curl_exec($curl);
    $info = curl_getinfo($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo print_r($response);
    }

    echo print_r($info);

And $response is always blank, and $info always shows me a 401 status code.

world-checkworld-check-oneerror-401php
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hello @d.marcella

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?


If so please can you click the 'Accept' text next to the appropriate reply. This will guide all community members who have a similar question.

Thanks,


AHS


@d.marcella

Hi,

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,

AHS

Upvote
Accepted
4.2k 8 5 6

@d.marcella

How are you defining your hmac function? Can you please provide the code snippet of the function that is generating the base64 encoded HMAC signature?


You will have to write a function to generate a HMAC and then append it in the authorization header as below.

Authorization: Signature keyId=\"{
                {API-KEY}}",algorithm=\"hmac-sha256\",headers=\"(request-target) host date\",signature=\"{
                {BASE64-HMAC}}\"" 

where { {BASE64-HMAC}} is the HMAC signature generated by hashing the API secret and the dataToSign variable.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
245 1 0 2

Hello @d.marcella


Unfortunately I do not have a straight answer for you, but please check https://community.developers.refinitiv.com/questions/26518/php-curl-response-is-blank.html because it was a similar issue that was already resolved.

Hope it will get you closer to your goal.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.