Put Method

Sends a PUT request to the server.

Syntax

public String put(String URI);

Remarks

This method sends the server a PUT request for the resource identified by URI. The RequestData property specifies the data that will be sent in the request. If the RequestContentFormat and/or RequestETag properties are non-empty, their values will be used to include Content-Format and Etag options in the request (respectively). Any additional options present in the RequestOptions collection will be included as well.

The format of the URI parameter is coap://hostname:port/resource. The port is optional, and if not specified will default to 5683. For instance coap://myserver/test and coap://myserver:5683/test are equivalent.

If the UseConfirmableMessages property is enabled when this method is called, the class will automatically retransmit the request message (if necessary) until it receives confirmation from the server that it was received. Note that the retransmission period is not infinite; eventually the class will assume that the message is undeliverable and time out the request.

If the Timeout property is greater than 0, this method will block until either a response is received, the specified timeout interval elapses, or (if UseConfirmableMessages is enabled) the retransmission period elapses; whichever occurs first. It will then return empty string.

If the Timeout property is 0, a record of the request will be added to the PendingRequests collection, and this method will finish immediately, returning an Id for the request. Passing this Id to the CancelRequest method will cancel the request (assuming it is still pending at that time).

Once a response is received, or the request times out, the class will do the following:

  • Populate the Response* properties (unless the request timed out).
  • Remove the request record from the PendingRequests collection, if necessary.
  • Fire the RequestComplete event.

Note: This method can only be called when the class is operating in client mode (i.e., when the Listening property is disabled).

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks IoT 2020 Java Edition - Version 20.0 [Build 8265]