1. Daniel Ferrreira
  2. PowerBuilder
  3. Thursday, 14 January 2021 03:25 AM UTC

Hi guys,
Can you please help me out here?

I'm trying to do this call using PB 2019 R2:

curl https://www.tiendanube.com/apps/authorize/token \
        --data \
        'client_id=123&client_secret=abcdef&grant_type=authorization_code&code=xyz'

 

Below is an image of the Postman call that works, although the values are fake.
All the other tabs have default values, I've only filled the Body tab.

 

This is my sample code, that returns this error:
{"error":"invalid_request","error_description":"The grant type was not specified in the request"}

String ls_body, ls_id, ls_secret
RestClient lRestClient

lRestClient = Create RestClient

ls_id = '123'; ls_secret = 'abcdef'; as_code = 'xyz';
ls_body = 'client_id=' + ls_id + '&client_secret=' + ls_secret + '&grant_type=authorization_code&code=' + as_code

ll_ret = lRestClient.sendPostRequest(ls_url, ls_body, ls_jsonRet)

 

Thanks a lot!!

 

Accepted Answer
Arthur Hefti Accepted Answer Pending Moderation
  1. Thursday, 14 January 2021 04:49 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi 

Try to set the header for Content Type to application/x-www-form-urlencoded

lRestClient.SetRequestHeader( "Content-Type", "application/x-www-form-urlencoded", TRUE )

Regards
Arthur

Comment
There are no comments made yet.
Daniel Ferrreira Accepted Answer Pending Moderation
  1. Thursday, 14 January 2021 09:52 AM UTC
  2. PowerBuilder
  3. # 1

Thank you very much, you nailed it!

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.