Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Screening /
  • World-Check One /

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

Overview |  Quickstart |  Documentation |  Downloads

avatar image
REFINITIV
Question by naoto.tatemichi · Aug 09, 2019 at 05:46 AM · world-checkworld-check-onephp

My PHP code doesn't convert continuous spaces in "dataToSign" string to generate signature

Hi, I created Pre-request script PHP code to hash dataToSign successfully in this question: how-to-generate-signature-by-curl-alone
It is for "Get my top-level groups" in Postman collection.

Now, I'm trying to do same on another Postman collection "Perform Synchronous Screening: Simple".
In the given Javascript sample by Postman.

Postman's Javascript code uses "dataToSign" string to generate signature which is like this:
{ "groupId":"my_group_id", "entityType": "INDIVIDUAL", "providerTypes": [ "WATCHLIST" ], "name": "putin", "secondaryFields":[], "customFields":[] }
As you can compare with below JSON file, it adds multiple spaces before "elements" to align as it looks in JSON format.


Here's the JSON file to load.

{
  "groupId":"<MY_GROUP_ID>",
  "entityType": "INDIVIDUAL",
  "providerTypes": [
    "WATCHLIST"
  ],
  "name": "putin",
  "secondaryFields":[],
  "customFields":[]
}

And here's my PHP code.

$load_content = file_get_contents($json_file);
$content = rtrim($load_content); // rtrim is required to remove carriage return at the end.

$dataToSign = "(request-target): post " . $gateway_url . "cases/screeningRequest" . "host: " . $gateway_host . "date: " . $time_gmt . "content-type: " . $content_env . "content-length: " . $content_decoded_length . $content;

Comparing $dataToSign between Postman's Javascript and my PHP code above, Postman adds multiple spaces before "elements" to align as it looks in JSON format, whereas my PHP code converts them to a single character which leads string mismatch.

Can anyone help on this?

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

3 Replies

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by naoto.tatemichi · Aug 15, 2019 at 07:59 AM

This is resolved by this code.

What mainly missing was carriage return "\n" in the $dataToSign.

$content = <<< EOM
{
  "groupId":"$group_id",
  "entityType": "INDIVIDUAL",
  "providerTypes": [
    "WATCHLIST"
  ],
  "name": "$screening_name",
  "secondaryFields":[],
  "customFields":[]
}
EOM;

$content_raw_length = iconv_strlen($content);

$dataToSign = "(request-target): post " . $gateway_url . "cases/screeningRequest\n" . "host: " . $gateway_host . "\n" . "date: " . $time_gmt . "\n" . "content-type: " . $content_env . "\n" . "content-length: " . $content_raw_length . "\n" . $content;
$hmac = base64_encode(hash_hmac('sha256', $dataToSign, $secret, true));
$authorisation = "Signature keyId=\"" . $api_key . "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date content-type content-length\",signature=\"" . $hmac . "\"";


Comment
Prabhjyot

People who like this

1 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
REFINITIV
Prabhjyot ♦♦ · Aug 19, 2019 at 08:57 AM 0
Share

@naoto.tatemichi ,

Thank you for your response and how you were able to resolve the issue. For further queries please raise a new query using the same forum.

I am accepting this answer to be correct on your behalf.

avatar image
REFINITIV
Answer by naoto.tatemichi · Aug 09, 2019 at 05:56 AM

Attaching my php code as carriage return collapsed.question-screening.txt


question-screening.txt (1.1 KiB)
Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
REFINITIV
Answer by Prabhjyot · Aug 12, 2019 at 07:31 AM

@naoto.tatemichi,

Thank you for your query.

Can you please refer to this link on how to calculate the content-length of the payload?

Also, from the provided code, it seems there will be a slight change in te dataToSign calculation.

$dataToSign = "(request-target): post " . $gateway_url . "cases/screeningRequest\n" . "host: " . $gateway_host . "\n" . "date: " . $time_gmt . "\n" . "content-type: " . $content_env . "\n" . "content-length: " . $content_length . "\n" . $group_id;

From the above formed dataToSign, instead of '$group-id' you have to pass the request payload content.

Please let us know if this helps.

Comment
naoto.tatemichi

People who like this

1 Show 3 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
REFINITIV
naoto.tatemichi · Aug 15, 2019 at 07:54 AM 1
Share

Hi @Prabhjyot.Mandla,

Thank you for your hint.
What I stuck was before cURL part.
I couldn't even generate correct $dataToSign.
Now I found what was wrong.

avatar image
ignacio.valenzuela naoto.tatemichi · Dec 16, 2020 at 12:19 AM 0
Share

Naoto, Could you please tell me what was wrong, I have the same problem and I can't fix it.

avatar image
REFINITIV
Prabhjyot ♦♦ ignacio.valenzuela · Dec 28, 2020 at 05:05 AM 0
Share

@naoto.tatemichi - Could you please advise @ignacio.valenzuela on the same as requested by the user?

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
12 People are following this question.

Related Questions

How to generate Signature in PHP any one help me ?

I need help for some confusion in API so clarify for given below question.

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

php return 401 Unauthorized response, but postman success

"cases/{ {case-system-id}}/screeningRequest" is not updating case results when called again after case update request

  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Electronic Trading
    • Generic FIX
    • Local Bank Node API
    • Trading API
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • FX Venues
    • FX Trading – RFQ Maker
  • Intelligent Tagging
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open Calais
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • RDMS
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • Workspace SDK
    • Element Framework
    • Grid
  • World-Check Data File
  • Yield Book Analytics
  • 中文论坛
  • Explore
  • Tags
  • Questions
  • Badges