Chilkat Online Tools

Classic ASP / New FreshBooks / List Items Filtered by SKU

Back to Collection Items

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

set http = Server.CreateObject("Chilkat_9_5_0.Http")

set queryParams = Server.CreateObject("Chilkat_9_5_0.JsonObject")
success = queryParams.UpdateString("search[sku]","{{sku}}")

' Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = "<access_token>"
http.SetRequestHeader "Content-Type","application/json"

' resp is a Chilkat_9_5_0.HttpResponse
Set resp = http.QuickRequestParams("GET","https://api.freshbooks.com/accounting/account/{{accountId}}/items/items",queryParams)
If (http.LastMethodSuccess = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( resp.StatusCode) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( resp.BodyStr) & "</pre>"


%>
</body>
</html>

Curl Command

curl -G -d "search[sku]=%7B%7Bsku%7D%7D"
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
https://api.freshbooks.com/accounting/account/{{accountId}}/items/items

Postman Collection Item JSON

{
  "name": "List Items Filtered by SKU",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "var jsonData = JSON.parse(responseBody);",
          "pm.environment.set(\"itemId\", jsonData.response.result.items[5].id);",
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "protocolProfileBehavior": {
    "disableBodyPruning": true
  },
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Content-Type",
        "name": "Content-Type",
        "type": "text",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": ""
    },
    "url": {
      "raw": "https://api.freshbooks.com/accounting/account/{{accountId}}/items/items?search%5Bsku%5D={{sku}}",
      "protocol": "https",
      "host": [
        "api",
        "freshbooks",
        "com"
      ],
      "path": [
        "accounting",
        "account",
        "{{accountId}}",
        "items",
        "items"
      ],
      "query": [
        {
          "key": "search%5Bsku%5D",
          "value": "{{sku}}"
        }
      ]
    },
    "description": "Returns an exact match of the searched SKU"
  },
  "response": [
  ]
}