At ESP8266 12E is blynk and is controlled through the app with Android device, but with the help Below code is not managed. What am I doing wrong? below shows examples of a response from the server and the code itself.
package ru.shapovalov.http_responce;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.MediaType;
public class Responce {
public Responce() {
}
public static void main(String[]args){
send();
}
protected static void send(){
Client client = ClientBuilder.newClient();
Entity payload = Entity.json("[“1”]");
Response response = client.target(“http://blynk-qa.cloudapp.net/My_token/pin/d12”)
.request(MediaType.APPLICATION_JSON_TYPE)
.put(payload);
System.out.println("status: " + response.getStatus());
System.out.println("headers: " + response.getHeaders());
System.out.println(“body:” + response.readEntity(String.class));
}
}
If sending “[” 1 \ “]” I get:
status: 200
headers: {Connection=[keep-alive]}
If sending “[]” I get: status: 400
headers: {Connection=[keep-alive], Content-Length=[27], Content-Type=[text/plain]}
body:No pin for update provided.
If sending “[‘1’]” I get: status: 500
headers: {Connection=[keep-alive], Content-Length=[31], Content-Type=[text/plain]}
body:Error parsing body param. [‘1’]