I have restAPI code from a programmer from JNE, the company stands for delivery service.
They say that this API can be run in POSTMAN (Google Chrome app)
It works fine in POSTMAN, where in this application I just need to insert the request URL (which I received from JNE) and two headers of keys and values, as shown below:
KEY VALUE ---------------------------------------------- username mycompany api key 4534645756864234523424
The method for this is POST , and when I posted it, it gives me the results as expected.
My problem now is how can I run this code on my page so that I donโt need to run this in the postman.
This day I'm going to find out JSON if anyone can help me.
[UPDATE QUESTION 1]
{ "version":1, "collections": [ { "id":"c8b12431-8586-cbdd-aef7-056ec177509a", "name":"asdasdadasdasdasd", "timestamp":1415593872130, "requests": [ { "collectionId":"c8b12431-8586-cbdd-aef7-056ec177509a", "id":"d1b2ed66-781d-d02e-c4eb-0416dd3e07a1", "name":"http://api.jne.co.id:8889/tracing/mycompany/origin/key/jak", "description":"", "url":"http://api.jne.co.id:8889/tracing/mycompany/origin/key/jak", "method":"POST", "headers":"username: mycompany\napi_key:089a12ffb8cd5009bdfa4ba5bdb9ee26\n", "data": [ { "key":"username", "value":"mycompany", "type":"text" }, { "key":"api_key", "value":"dsfsdfsdfs98d98sdfsdf9898dsfs", "type":"text" } ], "dataMode":"params", "timestamp":0, "responses":[], "version":2 } ] } ], "environments":[], "headerPresets":[], "globals":[] }
From the update question above; my first question is:]
In what format should I save this file: JSON? or what?
Should I save this file as a single file on my web page? Or can I save it as an external file?
From the above code, I get the result as follows:
{ "detail": [ { "code": "CGK10000", "label": "JAKARTA" }, { "code": "CGK10100", "label": "JAKARTA BARAT" }, { "code": "CGK10300", "label": "JAKARTA PUSAT" }, { "code": "CGK10200", "label": "JAKARTA SELATAN" }, { "code": "CGK10500", "label": "JAKARTA TIMUR" }, { "code": "CGK10400", "label": "JAKARTA UTARA" } ] }
If you look at the "label" , it is created from the key of the last line in: "name":"http://api.jne.co.id:8889/tracing/mycompany/origin/key/jak",
The result of the label from the last line of jak is what I want to insert in the html dropdown tag where the user will select this (location name).
[Update with full code]
POST /tracing/mycompany/origin/key/jak HTTP/1.1 Host: api.jne.co.id:8889 Content-Type: application/json username: mycompany api_key: 089a12ffb8cd5009bdfa4ba5bdb9ee26 { "version":1, "collections": [ { "id":"c8b12431-8586-cbdd-aef7-056ec177509a", "name":"asdasdadasdasdasd", "timestamp":1415593872130, "requests": [ { "collectionId":"c8b12431-8586-cbdd-aef7-056ec177509a", "id":"d1b2ed66-781d-d02e-c4eb-0416dd3e07a1", "name":"http://api.jne.co.id:8889/tracing/mycompany/origin/key/jakarta", "description":"", "url":"http://api.jne.co.id:8889/tracing/mycompany/origin/key/jakarta", "method":"POST", "headers":"username: mycompany\napi_key:089a12ffb8cd5009bdfa4ba5bdb9ee26\n", "data": [ { "key":"username", "value":"mycompany", "type":"text" }, { "key":"api_key", "value":"089a12ffb8cd5009bdfa4ba5bdb9ee26", "type":"text" } ], "dataMode":"params", "timestamp":0, "responses":[], "version":2 } ] } ], "environments":[], "headerPresets":[], "globals":[] }
I saved this file as jne.json and jne.html , but the browser just shows the complete code that shows the result, as the postman does. I think a lot of things are missing here.