DoPost JSON

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
TF-Itservices
Posts: 4
Joined: Tue Mar 08, 2022 6:32 pm

DoPost JSON

Post by TF-Itservices »

Hello all,

I am trying to execute this command :
#U_Request.DoPost( #HTTPpost ).

Unhappily we got respond code 401 back in the LANSA function .

Maybe there are some solutions to resolve this ?

Thanks

Twan Fréhé


Some source code :
Define_Com Class(#XPRIM_Json) Name(#json)
Define_Com Class(#XPRIM_JsonObject) Name(#jsonObj) Reference(*DYNAMIC)
Define_Com Class(#XPRIM_JsonObject) Name(#jsonpartijObj) Reference(*DYNAMIC)

* make root of JSON document
#jsonObj <= #json.CreateRootObject
* add Bearer token
* Value of token is get from another DoPost with right value!
#u_Request.Options.AddBearerAuthorization( #u_Token )
* archive
#jsonObj.SerializeToFile Path(#PATHNAMDOC) --> A archive document is set to the drive with right JSON lines without Bearer

* place JSON to content
#u_Request.Content.AddJson Value(#json)

* sent to URL
#U_Request.DoPost( #HTTPpost )

Checking respond after DoPost is code 401 Authorization.
User avatar
Dino
Posts: 472
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: DoPost JSON

Post by Dino »

quick suggestion, enable the tracing (viewtopic.php?f=3&t=2605&p=7702&hilit=lansaxlib#p7702) so you can see if the request is built correctly and the exact response you are getting. Maybe something is missing that you need to populate to get a successful post.
Post Reply