HMAC signature Content-Length

Options
MartyB
MartyB Newcomer
edited 7:17AM in World-Check One

Hello,

We have trouble sending a POST request to the WorldCheck One API. My assumption is that it has to do with the Content-Length header.

On this page there is an example request:

We have implemented an Azure Function using the Python script using the code samples (thanks for those!) but we get to another value for Content-Length, namely 80.

I think this is the reason that our request to the WorldCheck One API is not accepted.

image.png

How did you get to 88? And what are we doing wrong? Only when send the payload as string and I 'escape' all the double quotes, I get to 89, which is closer to 88, but still not the correct value.

image.png

Hope you can help!

Thanks.

Answers

  • Hi @MartyB,

    Thank you for reaching out, May I know what error are you receiving? Is it 401 - Unauthorized ?

    Regards,
    Ram.

  • MartyB
    MartyB Newcomer

    Yes it was 401.

    Working with compact JSON seems to have resolved the issue. The Python has been adapted:

    if payload is not None:

        content = json.dumps(payload, separators=(',', ':'))

        content_length = str(len(content.encode('utf-8')))

    And the call to the LSEG API has a body that is a string-representation of compact JSON,

    image.png

    This seems to create a match between the content-length from the python script, and the check that your system is doing.

  • @MartyB,

    We are glad that you were able to resolve the issue.
    Feel free to let us know if you need further assistance.

    Thanks,
    Ram.