Just going through the documentation on the notehub api for routes and I am a bit confused on the format of the requests.
Hi @rksteeves,
I wrote those docs and I can relate to your confusion, because Notehub routes have A LOT of options depending on the route type you are using.
To make it simpler, can you tell me what type of route you are trying to create with the Notehub API? I can then provide some sample API calls that may help clarify things.
Rob
Ultimately, I just want to update a route and change the token value.
However, I would like to understand the api a bit more than that. Lets say, in addition to the above, also create a route - http request route, with additional headers, with some kind of transformation, make the route active and what notes to apply to. That should provide me with what I need to get going. I am assuming what I dont specifically set up, the default with be used. ie rate limit, requests per min, time out?
thanks
randy
If you only want to update a token stored in a header inside an HTTP route, you would perform a request like this:
curl -X PUT
-L 'https://api.notefile.net/v1/projects/{projectUID}/routes/{routeUID}'
-H 'X-SESSION-TOKEN: {authToken}'
-d '{
"type":"http",
"http":{
"http_headers":{
"X-Auth-Token":"123456",
"another-token":"another-value"
}
}
}'
It’s a little confusing because the type
and schema
for http
routes use the same word! But really under the “schema” is where you place any and all properties you want to add/update (e.g. where http_headers
is found above).
And yes any omitted arguments will use defaults (when available, some are required of course).
I hope this helps!
Rob
Thanks Rob, that worked fine. I think one of the blocks I had was the schema. However, in looking back after your example and looking at some of the other stuff I have done, I think the thing that confused me was the use of {} for containing variables. Given the format is json, perhaps using <> to identify a variable would be more clear (at least to me). The other thing was the hierarchy, ie those elements that are within the “http”:{} (aka schema).
I am working on the create and have run into a 500 error, i have simplified things, but perhaps I am missing some required fields. Is there a minimal pieces of data to create a route? I have label, type, schema name and url.
randy
Excellent point about the {} vs <> for variable substitutions. We’ve gone back and forth on that. Will definitely make a note to revisit.
Can you PM me with the create route request you are trying to make? I’ll see if I can determine what the issue is.
Thanks,
Rob
I have done several. At this point if you could give me a minimal example of the least amount of data to create an http route, that would be great. I think but not sure that schema is part of the problem. in the arguments section it is listed as having a type string like label, but in the short example format, it seems to be listed as a value variable. I am doing this through python so here is the data string. I am guessing the headers and token are ok as I am using the same code, but in the create using a post rather than a put.
mytoken = resp.json()[‘session_token’]
headers = CaseInsensitiveDict()
headers[“X-SESSION-TOKEN”] = mytoken
data = ‘{“label”:“Route1”,“type”:“http”,“http”:{“url”:“https://content.dropboxapi.com/2/files/upload”}}’
url = “https://api.notefile.net/v1/projects/app:2596bdcd-c462-4eaf-98e1-fbd8be5b9b87/routes”
response = requests.post(url, headers=headers, data=data)
Got it. I’m headed out of town for the weekend but will put this at the top of my list for Monday!
Never mind, brute force and stubborness won out.
I sent a route request by id and worked backwards and created a “create route”. Only required a couple of modifications ie return value of False, has to be sent as false and empty arrray returned as None, has to be sent as .
At least I finished on a positive note today. Thanks for all the help
Randy