Resolved Using web API
- How-to
- Yasir Masood
- PowerBuilder
- Tuesday, 12 September 2023 07:12 PM UTC
Hi,
I am trying to use an API created in C# in my PB application. I am using PB Version 2017 R3 Build 1878.
To use the API, I need an Access Token that I am able to obtain using OAuthClient, TokenRequest and TokenResponse.
But I am not able to access the url with JSON.I get a return code of "415" and a response of "Unsupported Media Type".
Do I need get the latest version of PB to use this functionality?
Here is my code,
String ls_AccessToken
Long ll_return
long ll_ResponseStatusCode
string ls_ResponseStatusText
httpclient http
string ls_json
int li
string ls_res
ls_AccessToken = "Bearer " + ls_AccessToken
ls_url = "https://google.com"
ls_json = "{'carInit':'GATX','carNo':'000312'}"
http = create httpclient
ll_Return = http.ClearRequestHeaders ( )
http.AutoReadData = false
ll_Return = http.setrequestheader("Authorization" , ls_AccessToken)
ll_Return=0
ll_Return = http.sendrequest( 'POST', ls_url, ls_json)
li=http.GetResponseStatusCode()
ls_res = http.GetResponseStatusText()
Thank you for your help
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.