4. Sending Requests - nathan-fiscaletti/synful GitHub Wiki
What makes up a request to Synful?
- When sending a request to Synful, the
Synful-Auth
andSynful-Key
headers must both be set only if you are using a non-public RequestHandler (See Request Handlers: Request Handler Types). - Each request made to a Synful API must contain the properly formatted data depending on the Serializer that is being implemented.
Hint: Append
?pretty
the end of any endpoint that uses the JSONSerializer for output, and JSON_PRETTY_PRINT will be used.
Example Requests
Example 1
$ curl -vvvv \
-H "Content-Type: application/json" \
-H "Synful-Auth: SYNFUL" \
-H "Synful-Key: cb52b4d3776482a87d1706823b1135a5" \
-X POST \
-d '{"user_id":10}' \
http://127.0.0.1/users/get
This request will send a user ID to the RequestHandler with users/get
set as it's $endpoint
, using the API Key associated with the authentication handle SYNFUL
.
Based on the -d
data format, it is assumed that the RequestHandler is using the JSONSerializer.
It is also assumed that the RequestHandler has the post
Request Type function override implemented. (See Request Handlers: Request Type Functions.)
Example 2
$ curl -vvvv http://127.0.0.1/ip/get
This request will send an empty request to the RequestHandler with ip/get
set as it's $endpoint
. This RequestHandler is using the get
request type function by default when no request type is passed to the curl call. It is assumed that this RequestHandler is public
as the Synful-Auth
and Synful-Key
headers are not set.
Next: API Key Management