This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

WSC-RET-CODE=0000001401 calling "InvokeService04" (Web Service Provider)

I am trying to consume a Web Service API Rest Provider from a native COBOL program. To do this, I have created the Web Service Requester using the "imtkmake -genclientjson clientjson=json_name" command from OpenApi Schema, but when I make the call I get an error code 1401 (which I don't know what it means). Could someone tell me if the result of the aforementioned error can be found in any documentation?
Even so, I have managed to successfully consume another operation from the same Web Service Provider. In fact, the difference I'm seeing is that the operation I'm trying to consume that is failing has a URL parameter {polissa}, and this makes me suspect that this is the problem.
Finally, I've attached a piece of the code I'm using to make the call:
entry "getPolicy"
using getPolicy-parms.

move polissa
of input-parms
of getPolicy-parms
to wsc-polissa-op04I-01

set wsc-proc-ptr to entry "nxwscrun"

set wsc-ptr-arg(1)
to address of wsc-polissa-op04I-01
set wsc-ptr-arg(2)
to address of wsc-Policy-01

move 256 to wsc-srvc-faultcode-len
move 256 to wsc-srvc-faultstring-len

call "InvokeService04"
using value 2 -1 -1 -1 -1
reference
wsc-idt
wsc-ptr-args
wsc-srvc-address
n"getPolicy"
n"/policy/{polissa}"
n" "
wsc-srvc-querystring
wsc-srvc-username
wsc-srvc-password
value
wsc-srvc-address-len
9 17 1
wsc-srvc-querystring-len
wsc-srvc-username-len
wsc-srvc-password-len
reference
wsc-special-registers
wsc-spec-reg-lens
wsc-srvc-faultcode
wsc-srvc-faultcode-len
wsc-srvc-faultstring
wsc-srvc-faultstring-len
returning wsc-ret-code

if wsc-ret-code = 0

Labels:

Enterprise Developer
  • I think the error code that the Web Service Api Rest Provider is returning is "HTTP Status 401 – Unauthorized" even though it has a 1 in front of it ("1401"). Now the question is: How could the parameter "-H 'Authorization: Bearer" be indicated in the COBOL Web Service Api Rest Requester client?

    Also, I am attaching the result of the call with swagger specifying the "-H 'Authorization: Bearer" parameter and not specifying it to show that it is necessary to specify it to get an HTTP 200 return code.

    With NO Authorization:

    curl -X 'GET' \

      'http://oneip/policy/000002BE' \
      -H 'accept: application/json'

    Request URL

    http://one_ip/policy/000002BE

    Server response

    Code Details
    401

    Error: response status is 401

    With Authorizacion:

    curl -X 'GET' \
      'http://one_ip/policy/000002BE' \
      -H 'accept: application/json' \
      -H 'Authorization: Bearer one_token

    Request URL

    http://one_ip/policy/000002BE

    Server response

    Code Details
    200
  • Suggested Answer

    Hi Sergi,
    For this post I recommend you to consider raising a support case, then one of my colleagues can assist you further, research the issue/questions, provide information.