forbidden 403 while saving custom spots

29 views
Skip to first unread message

Alex Tiehuis

unread,
Mar 1, 2018, 6:58:28 AM3/1/18
to Dandelion Support Forum
I try to create custom spots with Ruby. Below my code which I entered in Rails Console:

token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
list = { spot: "Person 1", topic: "Employee" }, { spot: "Person 2", topic: "Employee" }, { spot: "Person 3", topic:"Employee" }
lang = "nl"
spots_description = "List of employees"
spots_params =  { data: { lang: lang, description: spots_description, list: list, token: token } } 
spots_uri = URI.parse(spots_url)
spots_response = Net::HTTP.post_form(spots_uri, spots_params)

The response I receive is: 
<Net::HTTPForbidden 403 Forbidden readbody=true>

JSON.parse(spots_response.body) gives following explanation:

{"error"=>true, "status"=>403, "code"=>"error.notAllowed", "message"=>"token param is missing", "data"=>{"parameter"=>"token"}}


Since I supply the token in the POST I figure it is in the wrong position.

Does anybody know what's wrong here?


Ugo Scaiella

unread,
Mar 1, 2018, 9:18:40 AM3/1/18
to Dandelion Support Forum
Hi Alex,

There are several issues there.

The first point is that API for creating the Custom Spost accepts 2 parameters: data, that is a string with the json serialization of a Custom Spots object, and token that is used to authenticate the user. Based on the code you posted, I can see that you are including the token parameter in the Custom Spots object (not as a parameter of the request) and you are not serializing the object as a json string. So, the spots_params should be something like this:

require 'json'
spots_params
=  { data: { lang: lang, description: spots_description, list: list}.to_json, token: token }

However, I can see that you are trying to create a Custom Spots object with language 'nl'. Unfortunately, we support Dutch language in beta and, in addition to some other limitations already stated in the documentation, the Custom Spots API does not work with beta languages. I understand that this is not clear from the documentation, we will amend it soon.

Best,
--
Ugo Scaiella
Dandelion API Team

Alex Tiehuis

unread,
Mar 1, 2018, 5:21:16 PM3/1/18
to Dandelion Support Forum
Thanks Ugo, that worked!

Not sure how updating custom spots should be programmed.
It seems that every time a new custom spots is generated.

Ugo Scaiella

unread,
Mar 5, 2018, 6:30:00 AM3/5/18
to Dandelion Support Forum
Hi Alex,

The custom-spots endpoint follows the CRUDL paradigm.
To update an object you must use the PUT method, see documentation for further details: https://dandelion.eu/docs/api/datatxt/custom-spots/v1/#update
Reply all
Reply to author
Forward
0 new messages