1. Home
  2. Docs
  3. API
  4. Parameters

Parameters

There are two different ways to pass parameters in a request with the API.

When passing parameters to create or update an object, parameters should be passed as a JSON object containing the appropriate attribute names and values as key-value pairs. When you use this format, you should specify that you are sending a JSON object in the header. This is done by setting the Content-Type header to application/json. This ensures that your request is interpreted correctly.

When passing parameters to filter a response on GET requests, parameters can be passed using standard query attributes. In this case, the parameters would be embedded into the URI itself by appending a ? to the end of the URI and then setting each attribute with an equal sign. Attributes can be separated with a &. Tools like curl can create the appropriate URI when given parameters and values; this can also be done using the -F flag and then passing the key and value as an argument. The argument should take the form of a quoted string with the attribute being set to a value with an equal sign.

PASS PARAMETERS AS A JSON OBJECT

curl -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"title": "New Project ABC", "work_category": "Building", "contract_number": "abc/123/def"}' \
    -X POST "https://eproject.buildspace.my/api/projects"

PASS FILTER PARAMETERS AS A QUERY STRING

curl -H "Authorization: Bearer $TOKEN" \
     -X GET \
     "https://eproject.buildspace.my/api/bills?pid=1234&limit=10"