Jump to content
alnickels

How to determine a resource and / or Resource suffix

Recommended Posts

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

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
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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×