Chilkat Online Tools

PowerBuilder / Coupa Postman Collection - OAuth - Master / Add Receipt to an Expense Line

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Req
oleobject loo_Resp

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Req = create oleobject
li_rc = loo_Req.ConnectToNewObject("Chilkat_9_5_0.HttpRequest")

loo_Req.HttpVerb = "POST"
loo_Req.Path = "/expense_reports/:expense_report_id/expense_lines/:expense_line_id/expense_artifacts"
loo_Req.ContentType = "multipart/form-data"
li_Success = loo_Req.AddFileForUpload2("file_input"," path to file","application/octet-stream")

loo_Req.AddHeader("Authorization","Bearer <access_token>")
loo_Req.AddHeader("Expect","100-continue")

loo_Resp = loo_Http.SynchronousRequest("domain.com",443,1,loo_Req)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Req
    return
end if

Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp


destroy loo_Http
destroy loo_Req

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	--form 'file_input=@"/path/to/file"'
https://domain.com/expense_reports/:expense_report_id/expense_lines/:expense_line_id/expense_artifacts

Postman Collection Item JSON

{
  "name": "Add Receipt to an Expense Line",
  "request": {
    "method": "POST",
    "header": [
    ],
    "body": {
      "mode": "formdata",
      "formdata": [
        {
          "key": "file_input",
          "type": "file",
          "src": "/Users/eshwarvalluripalli/Desktop/Screen Shot 2021-06-22 at 4.56.25 PM.png"
        }
      ]
    },
    "url": {
      "raw": "{{URL}}/expense_reports/:expense_report_id/expense_lines/:expense_line_id/expense_artifacts",
      "host": [
        "{{URL}}"
      ],
      "path": [
        "expense_reports",
        ":expense_report_id",
        "expense_lines",
        ":expense_line_id",
        "expense_artifacts"
      ],
      "variable": [
        {
          "key": "expense_report_id",
          "value": "6011"
        },
        {
          "key": "expense_line_id",
          "value": "84539"
        }
      ]
    }
  },
  "response": [
  ]
}