Repository navigation
Sending Requests
Martin Kim Dung-Pham edited this page Aug 28, 2017
·
8 revisions
Using the binary, you can send requests directly from the command line. In order to get the binary:
go install github.com/q231950/sputnik
sputnik requests post -p '{"query": {"recordType":"City"}, "resultsLimit": 1}' -o query -c iCloud.com.elbedev.bishcommunity
sputnik requests post -p '{"query": {"recordType":"City", "filterBy": [{"comparator": "EQUALS", "fieldName": "name", "fieldValue": {"value":"Tokyo"}}]}, "resultsLimit": 10}' -o query -c iCloud.com.elbedev.bishcommunity
sputnik requests post -j ./cmd/fixtures/sample_payload.json -o query -c iCloud.com.elbedev.bishcommunity
-o query marks the operation. As an example, for creating a record, the operation would be modify
-c iCloud.com... marks the container to access
Specification of the query:
-p '{"query": {"recordType":"City"}, "resultsLimit": 1}' is the payload of the request
or
-j './path/to/file.json' would add a payload using a path to a file
For more information, checkout the help:
sputnik help requests post
import (
keymanager "github.com/q231950/sputnik/keymanager"
requests "github.com/q231950/sputnik/requesthandling"
)
keyManager := keymanager.New()
config := requesthandling.RequestConfig{Version: "1", ContainerID: "iCloud.com...", Database: "public"}
requestManager := requesthandling.New(config, &keyManager)
request, error := requestManager.PostRequest("modify", json)
client := &http.Client{}
response, error := client.Do(request)...
request, error := requestManager.GetRequest("modify", json)
...