# - [smarthome](https://developers.home.google.com/reference/local-home/modules/smarthome.html).
- [DataFlow](https://developers.home.google.com/reference/local-home/modules/smarthome.dataflow.html).
- HttpRequestData

Request to send a local device command over HTTP.
Commands are sent to the device using [DeviceManager.send](https://developers.home.google.com/reference/local-home/interfaces/smarthome.devicemanager.html#send).

Example [GET](https://developers.home.google.com/reference/local-home/enums/smarthome.constants.httpoperation.html#get) request:

    const command = new DataFlow.HttpRequestData();
    command.requestId = request.requestId;
    command.deviceId = 'device-id';
    command.method = Constants.HttpOperation.GET;
    command.port = 80;
    command.path = '/endpoint/control?state=on';

Example [POST](https://developers.home.google.com/reference/local-home/enums/smarthome.constants.httpoperation.html#post) request:

    const postData = {
      on: true,
    };

    const command = new DataFlow.HttpRequestData();
    command.requestId = request.requestId;
    command.deviceId = 'device-id';
    command.method = Constants.HttpOperation.POST;
    command.port = 80;
    command.path = '/endpoint/control';
    command.dataType = 'application/json';
    command.data = JSON.stringify(postData);

[## Handle the response](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.httprequestdata#handle-the-response)

If the command succeeds, [DeviceManager.send](https://developers.home.google.com/reference/local-home/interfaces/smarthome.devicemanager.html#send) returns an
[HttpResponseData](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.httpresponsedata.html) result, which contains the [HttpResponse](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.httpresponse.html).

    const command = new DataFlow.HttpRequestData();
    ...

    localHomeApp.getDeviceManager()
     .send(command)
     .then((result: DataFlow.CommandSuccess) => {
       const httpResult = result as DataFlow.HttpResponseData;
       const responseBody = httpResult.httpResponse.body;
     })
     .catch((err: IntentFlow.HandlerError) => {
       // Handle command error
     });

### Implements

- [HttpRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.httprequestdata)

### Implemented by

- [HttpRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.httprequestdata)

## Index

### Properties

- [additionalHeaders](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.httprequestdata#additionalheaders)
- [data](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.httprequestdata#data)
- [dataType](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.httprequestdata#datatype)
- [deviceId](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.httprequestdata#deviceid)
- [headers](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.httprequestdata#headers)
- [method](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.httprequestdata#method)
- [path](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.httprequestdata#path)
- [port](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.httprequestdata#port)
- [protocol](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.httprequestdata#protocol)
- [requestId](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.httprequestdata#requestid)

## Properties

### additionalHeaders

additionalHeaders: {} Inherited from [HttpOptions](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.httpoptions.html).[additionalHeaders](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.httpoptions.html#additionalheaders)
Additional HTTP headers for the request, as an object containing
key/value pairs.

    {
      'Authorization': 'Bearer ...',
      'Accept': 'application/json',
    }

#### Type declaration

-

  ##### \[key: string\]: string

### data

data: string Inherited from [BleRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata).[data](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata#data)
Payload sent to the target device

### dataType

dataType: string Inherited from [HttpOptions](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.httpoptions.html).[dataType](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.httpoptions.html#datatype)
HTTP Content-Type header

### deviceId

deviceId: string Inherited from [BleRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata).[deviceId](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata#deviceid)
Device ID of the target device.

### headers

headers: string Inherited from [HttpOptions](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.httpoptions.html).[headers](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.httpoptions.html#headers)

deprecated

:   use [HttpRequestData.additionalHeaders](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.httprequestdata#additionalheaders)

List of HTTP headers for the request.

### method

method: [HttpOperation](https://developers.home.google.com/reference/local-home/enums/smarthome.constants.httpoperation.html) Inherited from [HttpOptions](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.httpoptions.html).[method](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.httpoptions.html#method)
HTTP method to perform

### path

path: string Inherited from [HttpOptions](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.httpoptions.html).[path](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.httpoptions.html#path)
URI path on the target device

### Optional port

port: undefined \| number Inherited from [HttpOptions](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.httpoptions.html).[port](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.httpoptions.html#port)
Port number on the target device. Default is port 80.

### protocol

protocol: [Protocol](https://developers.home.google.com/reference/local-home/enums/smarthome.constants.protocol.html) Inherited from [BleRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata).[protocol](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata#protocol)
Protocol to use when sending this command

### requestId

requestId: string Inherited from [BleRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata).[requestId](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata#requestid)
Request ID from the associated `EXECUTE` intent.