HttpResponse
The HttpResponse object allows returning data when sending uplink data through HTTP.
属性
statusCode (int) The statusCode property allows indicating the HTTP response status code. The default value for this property is 200 (OK).
示例
此示例 shows the creation of an HTTP response with status 200 and JSON content.
var httpResponse = new HttpReponse();
httpResponse.statusCode = 200;
httpResponse.contentType = "application/json";
httpResponse.content.setAsJson({ result: ultimo });contentType (string) The contentType property indicates the type of content that will be returned in the HTTP request.
示例
此示例 shows the creation of an HTTP response with status 200 and JSON content.
var httpResponse = new HttpReponse();
httpResponse.statusCode = 200;
httpResponse.contentType = "application/json";
httpResponse.content.setAsJson({ result: ultimo });方法
content.setAsJson(object) The content.setAsJson() method allows setting the response content in JSON format, with the data of the given object as parameter.
参数
- object (object): this parameter contains the object to be sent as a response. The object will be converted to JSON format.
示例
此示例 shows the creation of an HTTP response with status 200 and JSON content.
var httpResponse = new HttpReponse();
httpResponse.statusCode = 200;
httpResponse.contentType = "application/json";
httpResponse.content.setAsJson({ result: ultimo });content.setAsString(text) The content.setAsString() method allows setting the response content 使用 given text as parameter.
参数
- text (string): this parameter contains the text to be sent as a response.
示例
此示例 shows the creation of an HTTP response with status 200 and text content.
var httpResponse = new HttpReponse();
httpResponse.statusCode = 200;
httpResponse.contentType = "text/plain";
httpResponse.content.setAsString("This is some text");content.setAsBytes(bytes) The content.setAsBytes() method allows setting the response content in binary form, 使用 given data as parameter.
参数
- bytes (int[]): this parameter contains the byte array to be sent as a response.
示例
此示例 shows the creation of an HTTP response with status 200 and binary content of 5 bytes.
var httpResponse = new HttpReponse();
httpResponse.statusCode = 200;
httpResponse.contentType = "application/octet-stream";
httpResponse.content.setAsBytes([1, 2, 3, 4, 5]);端点 range
The endpoint range object allows indicating an acceptable range of values for an endpoint. 属性 lowestValue (double) The lowestValue property indicates the...
AI 副驾驶
Conversational, agentic AI assistant over your IoT telemetry — query devices, generate dashboards, and trigger actions in natural language.