Now I use arduino sending data to rails in json format. But how to get authenticity_token and send it to rails? Where it should be written ? In json or http header? What the format should be?
If I add
protect_from_forgery :exception => :create
In the controllers it works fine.But I do not want do disable the CSRF protection. This is my arduino code:
client.println("POST /players.json HTTP/1.1");
client.println("Host: 192.168.1.3:3000");
client.println("User-Agent: Arduino/1.0");
client.println("csrf-param: authenticity_token");
client.println("csrf-token: V4gTh8yNdz9VMybUXkI6tHxzAHdfk3I+UoiXhxZWK0bkoh8iG5hVJ5sZOjzMAYLlwCwsXQQM102b1hF6TVyYJw==");
client.println("Connection: close");
client.println(lengthInfo);
client.println("Content-Type: application/json");
client.println();
root.printTo(client);
root.printTo(client) just send son.
I found a similar question:
HTTP request to update rails model from arduino
@Okomikeruko Do you figure out how to send an authenticity token from Arduino?