-
Notifications
You must be signed in to change notification settings - Fork 70
feature: PUT Requests #507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6f02c44
feature: PUT Requests
sbender9 7d08997
docs: sync up with request/response PR
sbender9 d2ff961
docs: change result in examples to be HTTP codes
sbender9 777b955
docs: updated to reflect the latest request/response document
sbender9 fd8f0b3
docs: remove details about the put request from the response
sbender9 61ba808
Spelling
56160a5
Formatting
ef7c81c
change percentComplete to progress, provide definition
sbender9 a96aadd
Rename `result` to `statusCode`
sbender9 823324b
fix: json syntax
sbender9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| # PUT Requests | ||
|
|
||
| PUT requestes are sent to a server to request a change to a value. For example, a client would use PUT to switch the anchor light on or off, change the heading of the autopilot, or set position of the anchor. | ||
|
|
||
| See [Request/Response](request_response.md) for more details on request/response in Signal K. | ||
|
|
||
| ## Making a request to change a value | ||
| To change a value, a PUT request should be sent via HTTP or using a SignalK 'put' delta. | ||
|
|
||
| The "source" field is optional. If a request is sent without the source and their is more than one source for the value, that will result in a 400 HTTP error response. | ||
|
|
||
| ### via http | ||
| ``` | ||
| PUT http://localhost:3000/signalk/v1/api/vessels/self/steering/autopilot/target/headingTrue | ||
| { | ||
| "value" = 1.52, | ||
| "source": "actisense.204", | ||
| } | ||
| ``` | ||
|
|
||
| ### via a delta | ||
| ``` | ||
| { | ||
| "context": "vessels.self", | ||
| "correlationId": "184743-434373-348483", | ||
| "put": { | ||
| "path": "steering.autopilot.target.headingTrue", | ||
| "source": "actisense.204", | ||
| "value": 1.52 | ||
| } | ||
| } | ||
| ``` | ||
| ### HTTP Response when there's an error | ||
|
|
||
| HTTP response code 403: | ||
| JSON response body: | ||
| ``` | ||
| { | ||
| "state": "COMPLETED", | ||
| "result": 403 | ||
| } | ||
| ``` | ||
|
|
||
| ### HTTP Response to a successful PUT request | ||
|
|
||
| HTTP response code 200 (OK) | ||
| JSON response body: | ||
| ``` | ||
| { | ||
| "state": "COMPLETED", | ||
| "result": 202 | ||
| } | ||
| ``` | ||
|
|
||
| ### HTTP Response to a request that is being worked on asynchronously | ||
|
|
||
| The response in this case includes an optional `href` that can be used to check the status of the request. | ||
|
|
||
| HTTP response code 202 (Accepted) | ||
| JSON response body: | ||
| ``` | ||
| { | ||
| "href": "/signalk/v1/actions/12567" | ||
| } | ||
| ``` | ||
|
|
||
| #### Response to `/signalk/v1/actions/12567` when the request has completed successfully | ||
|
|
||
| ``` | ||
| { | ||
| "context" : "vessels.self", | ||
| "state": "COMPLETED" | ||
| "result" : 200, | ||
| } | ||
| ``` | ||
|
|
||
| #### Response to `/signalk/v1/actions/12567` when the request has failed | ||
|
|
||
| ``` | ||
| { | ||
| "context" : "vessels.self", | ||
| "state": "COMPLETED" | ||
| "result" : 502, | ||
| "message": "Unable to reach device", | ||
| } | ||
| ``` | ||
|
|
||
| #### Response to `/signalk/v1/api/actions/12567` when the request is pending | ||
| (note that percentComplete is optional) | ||
| ``` | ||
| { | ||
| "context" : "vessels.self", | ||
| "state": "PENDING", | ||
| "percentComplete": 0.45, | ||
| } | ||
| ``` | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.