PowerServer (PB Edition) 2020 Build 2323.00
PowerBuider 2019R2 Build 2353
Hello, i have two similar applications for web and mobile (Android) that consume a rest service using HTTPClient to create an event on google calendar using Google Calendar Api.
The app running on the web browser (and iwa) working great, but the same function fails on the mobile app returning a "400 Bad Request Error".
I've already tried a full deploy after updating the PowerServer Template Manager, also have tried different approaches on the mobile app but getting same error.
I've read somewhere that PowerServer Mobile 2020 supports HttpClient, am i wrong?
Any ideas?
tia,
simone
here is an example extrapolated from the method i'm using to communicate with the calendar api:
//creating the simple Json structure needed by calendar api
ls_string = '{"summary":"' + ls_rag + '","description":"' + is_tit_new + ' ' + char(13) +char(10) + is_des_new + '","location":"' + ls_loc + '",'
ls_string = ls_string + '"start":{"dateTime":"' + string(id_dataint_new, "yyyy-mm-dd") + ls_tini + '","timeZone":"Europe/Rome"},"end":{"dateTime":"' + string(id_dataint_new, "yyyy-mm-dd") + ls_tfin + '","timeZone":"Europe/Rome"},'
ls_string = ls_string + '"attendees":[{"displayName":"' + ls_nomeut + '","email":"' + ls_mailut + '"}]}'
//using the generated token before
ln_http = create httpclient
ls_URL = ls_gc_uri + '/calendars/' + calendarId + '/events'
as_conferenceDataVersion = '&conferenceDataVersion=' + string(conferenceDataVersion)
as_maxAttendees = '&maxAttendees=' + string(maxAttendees)
sendNotifications = '&sendNotifications=' + sendNotifications
supportsAttachments = '&supportsAttachments=' + supportsAttachments
ls_access = 'access_token=' + ls_access_token
ls_parm = ls_access + as_conferenceDataVersion + as_maxAttendees + sendNotifications + supportsAttachments
ls_url = ls_url + '?' + ls_parm
bdata = blob(ls_string, EncodingUTF8!)
ls_mime = 'application/json'
ln_http.SetRequestHeader("Content-Type", ls_mime)
li_ret = ln_http.sendrequest( 'POST', ls_url, bdata)
if li_ret = 1 then
li_rc = ln_http.GetResponseStatusCode()
ls_response = nvl(ln_http.getresponsestatustext( ), '')
if li_rc = 200 then //OK!
ln_http.GetResponseBody(ls_string)
rtparm = ls_string
destroy ln_http
return 1
else
ln_http.GetResponseBody(ls_string)
ls_string = '('+string(li_rc) + ') ' + ls_response + '~r~n'+ls_string
messagebox("of_post_events_insert", ls_string, stopsign!, ok!)
destroy ln_http
return 0
end if
else
messagebox("of_post_events_insert", "Connection error!", stopsign!, ok!)
destroy ln_http
return 0
end if