0

I'm building an integration with OKTA using APEX.

One of the actions I need to call is: get all the users which has updated in the past hour.

I'm executing the following code and get an error: 400 Bad Request.

Datetime dt = Datetime.now().addHours(-1);
string st_str = dt.formatGMT('yyyy-MM-dd\'T\'HH:mm:ss') + '.000Z';
endpoint = okta_base_url + '/api/v1/users?filter=lastUpdated gt "' + st_str +'"';  

system.debug('>>Sync_last_hour_users endpoint:' + endpoint);   
//https://dev.okta.com/api/v1/users?filter=lastUpdated gt "2018-07-26T08:00:46.000Z"

req.setEndpoint(endpoint);
req.setMethod('GET');
http_response = http.send(req);

in Postman this same call works perfectly, I guess the case is with the spaces after the 'filter'. I also tried:

https://dev.okta.com/api/v1/users?filter=lastUpdated&gt&"2018-07-26T08:00:46.000Z"
https://dev.okta.com/api/v1/users?filter=lastUpdated+gt+"2018-07-26T08:00:46.000Z"

but no good news here.

OKTA API documentation

Any idea?

2
  • 3
    As the documentation states, you need to replace spaces with %20 and quotes with %22 Jan 4, 2019 at 19:57
  • Thank you @CharlesKoppelman - that truly was the case here!
    – aralele
    Jan 6, 2019 at 8:23

0

You must log in to answer this question.

Browse other questions tagged .