alnickels 0 Posted September 23, 2019 I submit the following end point which has a API key that I do not wish to provide. I get a response in the debugger tool, but I do not know the resource or resource suffix to make it work in a project. Below is the response I get from the debugger. Note these endpoints do not have the nice .xml or .json extensions like the do in the Youtube example. Would love to know how to determine these values so that I can figure this from here. The endpoint below https://track.onestepgps.com/v3/api/public/device? Yes I left the ? but I removed the API key The results from running in the debugger below { "result_list": [ { "device_id":"6cnc3qPsQZHzH-81f07-0-", "created_at":null, "updated_at":"2019-06-20T06:22:29Z", "activated_at":"2019-02-19T01:18:53.244573Z", "delivered_at":null, "factory_id":"4562371099", "active_state":"active", "display_name":"F550", "bcc_id":"", "make":"calamp", "model":"3030 HSPA", "conn_type":"", "conn_data": { "calamp_next_lookup_time":null } , "settings": { "begin_moving_speed": { } , "begin_stopped_speed": { } , "max_drift_distance": { } , "max_hdop":null, "drive_timeout": { } , "stop_timeout": { } , "offline_timeout": { } , "history_calc_duration": { } } , "user_id_list": [ "6cA6O6RJQuLZKk81f07--V", "6cA6O6UQOo9ZKk81f07--V", "6cA6R8Z_PHLZKk81f07--V", "6clcLSCaPEeFxV81f07-0-", "6dp0oignNjaZWF81f07-0F" ] , "latest_device_point":null } , { "device_id":"6d3udZ-APYDQqV81f07-0-", "created_at":"2019-01-09T01:03:35Z", "updated_at":"2019-01-09T17:24:55Z", "activated_at":"2019-01-09T01:04:10.926502Z", "delivered_at":null, "factory_id":"R34542223348", "active_state":"none", "display_name":"orbcomm- 4542223348", "bcc_id":"", "make":"calamp", "model":"3030 CDMA 2G", "conn_type":"", "conn_data": { "calamp_next_lookup_time":null } , "settings": { "hidden":true, "begin_moving_speed": { } , "begin_stopped_speed": { } , "max_drift_distance": { } , "max_hdop":null, "drive_timeout": { } , "stop_timeout": { } , "offline_timeout": { } , "history_calc_duration": { } } , "user_id_list": [ "6cA6O6RJQuLZKk81f07--V", "6cA6O6UQOo9ZKk81f07--V", "6cA6PMvwQT5ZKk81f07--V", "6cA6R8Z_PHLZKk81f07--V", "6clcLSCaPEeFxV81f07-0-", "6dp0oignNjaZWF81f07-0F" ] , "latest_device_point":null } , { "device_id":"6d8lUOaQNw1fwk81f07-0-", "created_at":"2019-02-02T18:25:00Z", "updated_at":"2019-03-15T00:26:22Z", "activated_at":"2019-02-06T17:13:52.979652Z", "delivered_at":null, "factory_id":"R14762014590", "active_state":"none", "display_name":"Adam's - 23.15 test", "bcc_id":"", "make":"calamp", "model":"2030 HSPA", "conn_type":"", "conn_data": { "calamp_next_lookup_time":null } , "settings": { "hidden":true, "begin_moving_speed": { } , "begin_stopped_speed": { } , "max_drift_distance": { } , "max_hdop":null, "drive_timeout": { } , "stop_timeout": { } , "offline_timeout": { } , "history_calc_duration": { } } , "user_id_list": [ "6cA6O6RJQuLZKk81f07--V", "6cA6O6UQOo9ZKk81f07--V", "6cA6PMvwQT5ZKk81f07--V", "6cA6R8Z_PHLZKk81f07--V", "6clcLSCaPEeFxV81f07-0-", "6dp0oignNjaZWF81f07-0F" ] , "latest_device_point":null } ] } Results from executing as a URL {"result_list":[{"device_id":"6cnc3qPsQZHzH-81f07-0-","created_at":null,"updated_at":"2019-06-20T06:22:29Z","activated_at":"2019-02-19T01:18:53.244573Z","delivered_at":null,"factory_id":"4562371099","active_state":"active","display_name":"F550","bcc_id":"","make":"calamp","model":"3030 HSPA","conn_type":"","conn_data":{"calamp_next_lookup_time":null},"settings":{"begin_moving_speed":{},"begin_stopped_speed":{},"max_drift_distance":{},"max_hdop":null,"drive_timeout":{},"stop_timeout":{},"offline_timeout":{},"history_calc_duration":{}},"user_id_list":["6cA6O6RJQuLZKk81f07--V","6cA6O6UQOo9ZKk81f07--V","6cA6R8Z_PHLZKk81f07--V","6clcLSCaPEeFxV81f07-0-","6dp0oignNjaZWF81f07-0F"],"latest_device_point":null},{"device_id":"6d3udZ-APYDQqV81f07-0-","created_at":"2019-01-09T01:03:35Z","updated_at":"2019-01-09T17:24:55Z","activated_at":"2019-01-09T01:04:10.926502Z","delivered_at":null,"factory_id":"R34542223348","active_state":"none","display_name":"orbcomm- 4542223348","bcc_id":"","make":"calamp","model":"3030 CDMA 2G","conn_type":"","conn_data":{"calamp_next_lookup_time":null},"settings":{"hidden":true,"begin_moving_speed":{},"begin_stopped_speed":{},"max_drift_distance":{},"max_hdop":null,"drive_timeout":{},"stop_timeout":{},"offline_timeout":{},"history_calc_duration":{}},"user_id_list":["6cA6O6RJQuLZKk81f07--V","6cA6O6UQOo9ZKk81f07--V","6cA6PMvwQT5ZKk81f07--V","6cA6R8Z_PHLZKk81f07--V","6clcLSCaPEeFxV81f07-0-","6dp0oignNjaZWF81f07-0F"],"latest_device_point":null},{"device_id":"6d8lUOaQNw1fwk81f07-0-","created_at":"2019-02-02T18:25:00Z","updated_at":"2019-03-15T00:26:22Z","activated_at":"2019-02-06T17:13:52.979652Z","delivered_at":null,"factory_id":"R14762014590","active_state":"none","display_name":"Adam's - 23.15 test","bcc_id":"","make":"calamp","model":"2030 HSPA","conn_type":"","conn_data":{"calamp_next_lookup_time":null},"settings":{"hidden":true,"begin_moving_speed":{},"begin_stopped_speed":{},"max_drift_distance":{},"max_hdop":null,"drive_timeout":{},"stop_timeout":{},"offline_timeout":{},"history_calc_duration":{}},"user_id_list":["6cA6O6RJQuLZKk81f07--V","6cA6O6UQOo9ZKk81f07--V","6cA6PMvwQT5ZKk81f07--V","6cA6R8Z_PHLZKk81f07--V","6clcLSCaPEeFxV81f07-0-","6dp0oignNjaZWF81f07-0F"],"latest_device_point":null}]} Share this post Link to post
aehimself 396 Posted September 24, 2019 Hello, I will be honest I don't understand the question correctly, but if you'd like to identify if the received string is a JSON or an XML, you can use this: Uses System.JSON; [...] Var x: TJSONValue; begin x := TJSONObject.ParseJSONValue('this is the received file'); If x = nil Then Begin // File is NOT JSON -> it is XML (or other webserver generated error page) End Else Begin // File is JSON, values can now be accessed by object "x" End; end; In the x = nil branch you could make an XML-to-object parsing to confirm if it's XML and simply stop processing if not. I never worked with XMLs from my codes so I have no knowledge on how to do that, though 😞 Share this post Link to post
Remy Lebeau 1391 Posted September 24, 2019 On 9/23/2019 at 5:54 AM, alnickels said: Note these endpoints do not have the nice .xml or .json extensions like the do in the Youtube example. Would love to know how to determine these values so that I can figure this from here. The response's "Content-Type" header tells you the exact format of the data, such as " application/json", "application/xml", etc. Share this post Link to post
aehimself 396 Posted September 24, 2019 1 hour ago, Remy Lebeau said: The response's "Content-Type" header tells you the exact format of the data, such as " application/json", "application/xml", etc. Ouch. Why I always tend to overcomplicate things? 🙂 This is the correct solution. Share this post Link to post