You need to sign in to do that
Don't have an account?
Neha Aggrawal
TeamUp Http Request
Hi,
I am calling teamup API from Salesforce to get events data. This is my apex code:
I am getting 403 Forbidden error. This is the request sent from Adavnced Rest Client, where I am getting back the event details successfully.
Any help is appreciated.
Thanks.
I am calling teamup API from Salesforce to get events data. This is my apex code:
global class EventsTeamUp { @future(callout=true) Public Static Void UpdateEvents(){ HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); String result; Http http = new Http(); datetime dt=System.now(); dt=dt-(1); String d=dt.format('yyyy-MM-dd'); List<Event> eventlist = new List<Event>(); req.setMethod('GET' ); req.setEndpoint('https://api.teamup.com/ks6mg6ziqj7cgg84qz/events?startDate='+d+'&endDate='+d); Blob headerValue = Blob.valueOf('teamup-token' + ':' + 'e1bb9869fab6320f4ff7ca23eeb48b80a9e113396b903d794d9e3fcaf857ff3f'); String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue); req.setHeader('Authorization', 'authorizationHeader'); try{ res=http.send(req); result=res.getBody(); Map<String, String> values = (Map<String, String>) JSON.deserialize(res.getBody(), Map<String, String>.class); System.debug(values); for(String key : values.keySet()) { Event e= new Event(IsAllDayEvent=Boolean.valueOf(values.get('all_day')), Subject=values.get('title'), StartDateTime=DateTime.parse(values.get('start_dt')), EndDateTime=DateTime.parse(values.get('end_dt')), Location=values.get('location'), Description=values.get('notes')+'Invitees:'+values.get('who')); eventlist.add(e); } insert eventlist; } catch(Exception e) { System.debug('The following exception has occurred: ' + e.getMessage()); } } }
I am getting 403 Forbidden error. This is the request sent from Adavnced Rest Client, where I am getting back the event details successfully.
Any help is appreciated.
Thanks.
Here is the working code Please try this
Result:
Thanks
Ramesh
All Answers
Here is the working code Please try this
Result:
Thanks
Ramesh
That worked.