Welcome! Log In Create A New Profile

Advanced

one question about rest api and token

Posted by LasseS 
one question about rest api and token
July 01, 2023 11:56AM
Hi,
I have still problem with this code, how to set token as it comes ok but it is worng format, I have
tried authtoken and token variables but no difference.

----
LOCAL
sClientID, sClientPASS, sVendorAPI, sURL are strings
sJson is JSON

sRestReq is restRequest
sRestRes is restResponse

sClientID = "87727352-e721-4de6-bc68-b6bb9ad0e05f" //for testing
sClientPASS = "3cba3580-a404-40a0-abf0-d786a9062d36" //for testing
sVendorAPI = "ba49a7d8-9cf3-444d-b3ba-b0c3e0d6252e" //tor testinh
sURL = "[ax-stage.maventa.com];

sJson.client_id = sClientID
sJson.client_secret = sClientPASS
sJson.vendor_api_key = sVendorAPI
sJson.grant_type = "client_credentials"
sJson.scope = "invoice:send invoice:receive"
sRestReq.Method = httpPost
sRestReq.URL = sURL + "oauth2/token"
sRestReq.ContentType = typeMimeJSON
sRestReq.Content = sJson
sRestRes = RESTSend( sRestReq )

Info( sRestRes.Content )

sRestReq.AuthToken = sRestRes.Content
sRestReq.URL = sURL + "v1/invoices"
sRestReq.Header[ "format=FINVOICE30" ]
sRestReq.Header[ "recipient_type=b2b" ]
sRestReq.Header[ "recipient_operator=003721291126" ]
sRestReq.Header[ "disabled-routes=print,email" ]
sRestReq.Header[ "file=C:\erpKasoori\FinvoiceXML\20230629_40_Lapela Oy_Finvoice.xml" ]
sRestReq.Method = httpPost
sRestReq.ContentType = typeMimeXMLText
sRestRes = HTTPSend( sRestReq )

----

Are there anybody that can tell what is worng with this as swagge it works very but not in windev code
[swagger.maventa.com]

best regards,

Lasse Sandström
Re: one question about rest api and token
July 01, 2023 12:51PM
Something is going on...

maybe you have an improved code or it was unfinished...

So: sURL = "[ax-stage.maventa.com]; == ERROR

maybe? sURL = "[ax-stage.maventa.com"];
PS: my error, phorum edits this in [] sry...

BUT: sRestReq.URL = sURL + "oauth2/token"

missing a /

SHOULD BE? sURL + "/oauth2/token"

yours
Alex



Edited 1 time(s). Last edit at 07/01/2023 12:52PM by apredl.
Re: one question about rest api and token
July 01, 2023 02:07PM
but in my code this sURL is

sURL = [ax-stage.maventa.com]

and thera is also this '/'



Edited 1 time(s). Last edit at 07/01/2023 02:08PM by LasseS.
Re: one question about rest api and token
July 01, 2023 02:09PM
this form changes format as there quote " before and after and '/' also right place
Re: one question about rest api and token
July 01, 2023 02:11PM
as you seen in my code there is this '/'
Attachments:
open | download - Näyttökuva 2023-07-01 150957.png (102.7 KB)
Re: one question about rest api and token
July 01, 2023 04:22PM
problem is how to change json token sRestReq.content to sRestReq.AuthToken as
there comes this error message:

An element of type 'Ansi String' cannot be converter to 'advanced'



Edited 1 time(s). Last edit at 07/01/2023 04:22PM by LasseS.
Re: one question about rest api and token
July 02, 2023 12:38PM
Hi Lasse,
maybe your problem is with UTF8 (since your project looks like it is in ANSI) ?

Regards
Steven Sitas
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: