PowerShell Concur: Create a Receipt without an Image (from JSON string)

Back to Index

Posts a receipt without an image. A successful POST will result in a 201 status code with an empty response.

Documentation: https://developer.concur.com/api-reference/receipts/endpoints.html#endpoint-post-a-receipt

CURL Command

curl -v -X POST https://us.api.concursolutions.com/receipts/v4/users/USER_ID \
-H "Authorization: Bearer {YOUR ACCESS TOKEN}" \
-H "Content-Type: application/json" \
-H "link: <http://schema.concursolutions.com/VALIDATION_SCHEMA_FROM_SCHEMA_ENDPOINT.schema.json>;rel=describedBy" \
-d '{
    "taxInvoice": true,
    "reference": "6343430",
    "dateTime": "2016-09-29T15:05:00-0800",
    "total": "749.95",
    "subtotal": "652.67",
    "taxesTotal": "97.28",
    "currencyCode": "CAD",
    "seller": {
        "name": "ACME Corporation",
        "description": "",
        "taxId": "123-21213",
        "location": {
            "name": "ACME Hotels",
            "number": "ACME34393",
            "latitude": 47.616667,
            "longitude": -122.333333,
            "internetAddress": "https://www.acmecorporation.com",
            "emailAddress": "sna_hotel@acmecorporation.com",
            "telephoneNumber": "123-456-7890",
            "faxNumber": "",
            "address": {
                "streetAddress": "1 Hotel Way",
                "addressLocality": "Seattle",
                "addressRegion": "WA",
                "addressCountry": "US",
                "postalCode": "90001"
            }
        }
    },
    "taxes": [
        {
            "authority": {
                "addressCountry": "CA"
            },
            "name": "Hotel Room Tax",
            "rate": 11.00,
            "amount": "66.88"
        },
        {
            "authority": {
                "addressCountry": "CA"
            },
            "name": "GST",
            "rateType": "Standard",
            "rate": 5.00,
            "amount": "30.4"
        }
    ],
    "payments": [
        {
            "amount": "749.95",
            "cardDetail": {
                "cardType": "American Express",
                "creditCardId": "1002",
                "authorizationCode": "548283"
            }
        }
    ],
    "property": {
        "name": "Grand Hotel",
        "number": "",
        "latitude": 49.280011,
        "longitude": -123.117024,
        "internetAddress": "",
        "emailAddress": "",
        "telephoneNumber": "123-456-1999",
        "faxNumber": "123-456-2502",
        "address": {
            "streetAddress": "433 Hotel Street",
            "addressLocality": "Vancouver",
            "addressRegion": "BC",
            "addressCountry": "CA",
            "postalCode": "v6b 6l9"
        }
    },
    "checkInDateTime": "2016-08-25T21:11:00-0700",
    "checkOutDateTime": "2016-08-27T11:09:00-0700",
    "guests": [
        {
            "guestNameRecord": "ACME-Axxxxxxx1899",
            "firstName": "Jon",
            "lastName": "Snow",
            "address": {
                "streetAddress": "111 Black Castle",
                "addressLocality": "Toronto",
                "addressRegion": "ON",
                "addressCountry": "CA",
                "postalCode": "M2P 2B8"
            }
        }
    ],
    "numberInParty": 1,
    "room": {
        "roomNumber": "1601",
        "averageDailyRoomRate": "304.00"
    },
    "nightsStayed": 2,
    "lineItems": [
        {
            "sequenceNumber": 1,
            "dateTime": "2016-04-25T18:00:00-0700",
            "reference": "RT1601",
            "description": "Room Chrg Retail",
            "semanticsCode": "ROOMRATE",
            "quantity": 1,
            "total": "304.00",
            "taxes": [
                {
                    "authority": {
                        "addressCountry": "CA"
                    },
                    "name": "Hotel Room Tax",
                    "rate": 11.00,
                    "amount": "33.44"
                },
                {
                    "authority": {
                        "addressCountry": "CA"
                    },
                    "name": "GST",
                    "rateType": "Standard",
                    "rate": 5.00,
                    "amount": "15.20"
                }
            ]
        },
        {
            "sequenceNumber": 2,
            "dateTime": "2016-04-25T18:00:00-0700",
            "reference": "RT1601",
            "description": "Destination Marketing Fee",
            "semanticsCode": "FEE",
            "quantity": 1,
            "total": "4.56"
        },
        {
            "sequenceNumber": 3,
            "dateTime": "2016-04-26T18:00:00-0700",
            "reference": "4071",
            "description": "Hidden Bar and Lounge",
            "semanticsCode": "MINIBAR",
            "quantity": 1,
            "total": "31.55"
        },
        {
            "sequenceNumber": 4,
            "dateTime": "2016-04-26T18:00:00-0700",
            "reference": "RT1601",
            "description": "Room Chrg Retail",
            "semanticsCode": "ROOMRATE",
            "quantity": 1,
            "total": "304.00",
            "taxes": [
                {
                    "authority": {
                        "addressCountry": "CA"
                    },
                    "name": "Hotel Room Tax",
                    "rate": 11.00,
                    "amount": "33.44"
                },
                {
                    "authority": {
                        "addressCountry": "CA"
                    },
                    "name": "GST",
                    "rateType": "Standard",
                    "rate": 5.00,
                    "amount": "15.20"
                }
            ]
        },
        {
            "sequenceNumber": 5,
            "dateTime": "2016-04-26T18:00:00-0700",
            "reference": "RT1601",
            "description": "Destination Marketing Fee",
            "semanticsCode": "FEE",
            "quantity": 1,
            "total": "4.56"
        }
    ]
}'

PowerShell Example

[Reflection.Assembly]::LoadFile("C:\myAssemblies\ChilkatDotNet2.dll")

$rest = New-Object Chilkat.Rest

#  URL: https://us.api.concursolutions.com/receipts/v4/users/USER_ID
$bTls = $true
$port = 443
$bAutoReconnect = $true
$success = $rest.Connect("us.api.concursolutions.com",$port,$bTls,$bAutoReconnect)
if ($success -ne $true) {
    $("ConnectFailReason: " + $rest.ConnectFailReason)
    $($rest.LastErrorText)
    exit
}

$json = New-Object Chilkat.JsonObject
$json.UpdateBool("taxInvoice",$true)
$json.UpdateString("reference","6343430")
$json.UpdateString("dateTime","2016-09-29T15:05:00-0800")
$json.UpdateString("total","749.95")
$json.UpdateString("subtotal","652.67")
$json.UpdateString("taxesTotal","97.28")
$json.UpdateString("currencyCode","CAD")
$json.UpdateString("seller.name","ACME Corporation")
$json.UpdateString("seller.description","")
$json.UpdateString("seller.taxId","123-21213")
$json.UpdateString("seller.location.name","ACME Hotels")
$json.UpdateString("seller.location.number","ACME34393")
$json.UpdateNumber("seller.location.latitude","47.616667")
$json.UpdateNumber("seller.location.longitude","-122.333333")
$json.UpdateString("seller.location.internetAddress","https://www.acmecorporation.com")
$json.UpdateString("seller.location.emailAddress","sna_hotel@acmecorporation.com")
$json.UpdateString("seller.location.telephoneNumber","123-456-7890")
$json.UpdateString("seller.location.faxNumber","")
$json.UpdateString("seller.location.address.streetAddress","1 Hotel Way")
$json.UpdateString("seller.location.address.addressLocality","Seattle")
$json.UpdateString("seller.location.address.addressRegion","WA")
$json.UpdateString("seller.location.address.addressCountry","US")
$json.UpdateString("seller.location.address.postalCode","90001")
$json.UpdateString("taxes[0].authority.addressCountry","CA")
$json.UpdateString("taxes[0].name","Hotel Room Tax")
$json.UpdateNumber("taxes[0].rate","11.00")
$json.UpdateString("taxes[0].amount","66.88")
$json.UpdateString("taxes[1].authority.addressCountry","CA")
$json.UpdateString("taxes[1].name","GST")
$json.UpdateString("taxes[1].rateType","Standard")
$json.UpdateNumber("taxes[1].rate","5.00")
$json.UpdateString("taxes[1].amount","30.4")
$json.UpdateString("payments[0].amount","749.95")
$json.UpdateString("payments[0].cardDetail.cardType","American Express")
$json.UpdateString("payments[0].cardDetail.creditCardId","1002")
$json.UpdateString("payments[0].cardDetail.authorizationCode","548283")
$json.UpdateString("property.name","Grand Hotel")
$json.UpdateString("property.number","")
$json.UpdateNumber("property.latitude","49.280011")
$json.UpdateNumber("property.longitude","-123.117024")
$json.UpdateString("property.internetAddress","")
$json.UpdateString("property.emailAddress","")
$json.UpdateString("property.telephoneNumber","123-456-1999")
$json.UpdateString("property.faxNumber","123-456-2502")
$json.UpdateString("property.address.streetAddress","433 Hotel Street")
$json.UpdateString("property.address.addressLocality","Vancouver")
$json.UpdateString("property.address.addressRegion","BC")
$json.UpdateString("property.address.addressCountry","CA")
$json.UpdateString("property.address.postalCode","v6b 6l9")
$json.UpdateString("checkInDateTime","2016-08-25T21:11:00-0700")
$json.UpdateString("checkOutDateTime","2016-08-27T11:09:00-0700")
$json.UpdateString("guests[0].guestNameRecord","ACME-Axxxxxxx1899")
$json.UpdateString("guests[0].firstName","Jon")
$json.UpdateString("guests[0].lastName","Snow")
$json.UpdateString("guests[0].address.streetAddress","111 Black Castle")
$json.UpdateString("guests[0].address.addressLocality","Toronto")
$json.UpdateString("guests[0].address.addressRegion","ON")
$json.UpdateString("guests[0].address.addressCountry","CA")
$json.UpdateString("guests[0].address.postalCode","M2P 2B8")
$json.UpdateNumber("numberInParty","1")
$json.UpdateString("room.roomNumber","1601")
$json.UpdateString("room.averageDailyRoomRate","304.00")
$json.UpdateNumber("nightsStayed","2")
$json.UpdateNumber("lineItems[0].sequenceNumber","1")
$json.UpdateString("lineItems[0].dateTime","2016-04-25T18:00:00-0700")
$json.UpdateString("lineItems[0].reference","RT1601")
$json.UpdateString("lineItems[0].description","Room Chrg Retail")
$json.UpdateString("lineItems[0].semanticsCode","ROOMRATE")
$json.UpdateNumber("lineItems[0].quantity","1")
$json.UpdateString("lineItems[0].total","304.00")
$json.UpdateString("lineItems[0].taxes[0].authority.addressCountry","CA")
$json.UpdateString("lineItems[0].taxes[0].name","Hotel Room Tax")
$json.UpdateNumber("lineItems[0].taxes[0].rate","11.00")
$json.UpdateString("lineItems[0].taxes[0].amount","33.44")
$json.UpdateString("lineItems[0].taxes[1].authority.addressCountry","CA")
$json.UpdateString("lineItems[0].taxes[1].name","GST")
$json.UpdateString("lineItems[0].taxes[1].rateType","Standard")
$json.UpdateNumber("lineItems[0].taxes[1].rate","5.00")
$json.UpdateString("lineItems[0].taxes[1].amount","15.20")
$json.UpdateNumber("lineItems[1].sequenceNumber","2")
$json.UpdateString("lineItems[1].dateTime","2016-04-25T18:00:00-0700")
$json.UpdateString("lineItems[1].reference","RT1601")
$json.UpdateString("lineItems[1].description","Destination Marketing Fee")
$json.UpdateString("lineItems[1].semanticsCode","FEE")
$json.UpdateNumber("lineItems[1].quantity","1")
$json.UpdateString("lineItems[1].total","4.56")
$json.UpdateNumber("lineItems[2].sequenceNumber","3")
$json.UpdateString("lineItems[2].dateTime","2016-04-26T18:00:00-0700")
$json.UpdateString("lineItems[2].reference","4071")
$json.UpdateString("lineItems[2].description","Hidden Bar and Lounge")
$json.UpdateString("lineItems[2].semanticsCode","MINIBAR")
$json.UpdateNumber("lineItems[2].quantity","1")
$json.UpdateString("lineItems[2].total","31.55")
$json.UpdateNumber("lineItems[3].sequenceNumber","4")
$json.UpdateString("lineItems[3].dateTime","2016-04-26T18:00:00-0700")
$json.UpdateString("lineItems[3].reference","RT1601")
$json.UpdateString("lineItems[3].description","Room Chrg Retail")
$json.UpdateString("lineItems[3].semanticsCode","ROOMRATE")
$json.UpdateNumber("lineItems[3].quantity","1")
$json.UpdateString("lineItems[3].total","304.00")
$json.UpdateString("lineItems[3].taxes[0].authority.addressCountry","CA")
$json.UpdateString("lineItems[3].taxes[0].name","Hotel Room Tax")
$json.UpdateNumber("lineItems[3].taxes[0].rate","11.00")
$json.UpdateString("lineItems[3].taxes[0].amount","33.44")
$json.UpdateString("lineItems[3].taxes[1].authority.addressCountry","CA")
$json.UpdateString("lineItems[3].taxes[1].name","GST")
$json.UpdateString("lineItems[3].taxes[1].rateType","Standard")
$json.UpdateNumber("lineItems[3].taxes[1].rate","5.00")
$json.UpdateString("lineItems[3].taxes[1].amount","15.20")
$json.UpdateNumber("lineItems[4].sequenceNumber","5")
$json.UpdateString("lineItems[4].dateTime","2016-04-26T18:00:00-0700")
$json.UpdateString("lineItems[4].reference","RT1601")
$json.UpdateString("lineItems[4].description","Destination Marketing Fee")
$json.UpdateString("lineItems[4].semanticsCode","FEE")
$json.UpdateNumber("lineItems[4].quantity","1")
$json.UpdateString("lineItems[4].total","4.56")

$rest.AddHeader("link","<http://schema.concursolutions.com/VALIDATION_SCHEMA_FROM_SCHEMA_ENDPOINT.schema.json>;rel=describedBy")
$rest.AddHeader("Content-Type","application/json")
$rest.AddHeader("Authorization","Bearer {YOUR ACCESS TOKEN}")

$sbRequestBody = New-Object Chilkat.StringBuilder
$json.EmitSb($sbRequestBody)
$sbResponseBody = New-Object Chilkat.StringBuilder
$success = $rest.FullRequestSb("POST","/receipts/v4/users/USER_ID",$sbRequestBody,$sbResponseBody)
if ($success -ne $true) {
    $($rest.LastErrorText)
    exit
}

$respStatusCode = $rest.ResponseStatusCode
if ($respStatusCode -ge 400) {
    $("Response Status Code = " + $respStatusCode)
    $("Response Header:")
    $($rest.ResponseHeader)
    $("Response Body:")
    $($sbResponseBody.GetAsString())
    exit
}