Skip to Content

How to send custom http header element(API Key) using CL_HTTP_CLIENT

Hello,

I am trying to do a REST API Call(GET) from ECC to a third party system and need to pass the API Key as a custom HTTP Header element. We are unable to do this via PI's REST Adapter as we are still on 7.4 SP 9.

I am using CL_HTTP_CLIENT class and added the custom HTTP Header element via set_header_field method but I get 401 Unauthorized. The same request is going through fine from postman.

Our ECC is on 7.4 SP7. Can't we pass custom http headers from ECC on this SP level?

Thanks,

Sarat

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Mar 18 at 08:54 PM
    -1

    Hi Sandra,

    I have increased the trace via SMICM and found the root cause. Somehow, the API key is getting truncated in the HTTP request. I checked the "Value" field of the method "set_header_field" of "request" attribute of cl_http_client class that I am using to set the header element and the variable is of type "String". So not sure how my API Key data is getting truncated.

    Thoughts?

    Thanks,

    Sarat

    Add comment
    10|10000 characters needed characters exceeded