Skip to content

Instantly share code, notes, and snippets.

@bwghughes
Last active June 3, 2016 08:59
Show Gist options
  • Save bwghughes/ce27a04ae5bba723a897503bf3b6211b to your computer and use it in GitHub Desktop.
Save bwghughes/ce27a04ae5bba723a897503bf3b6211b to your computer and use it in GitHub Desktop.
import os
import json
import requests
import logging
logging.basicConfig(level=logging.INFO)
log = logging.getLogger(__name__)
url = "http://0ba03adb.ngrok.io/api.rsc/BillExpenseItems"
body = {
"ExpenseLineId": "21",
"ExpenseAccountId": "6001",
"ExpenseAmount": "10.00",
"VendorID": "800002CA-1464931068",
}
headers = {"Content-Type": "application/json",
"x-cdata-authtoken": os.getenv('CDATA_TOKEN')}
resp = requests.post(url, json.dumps(body), headers=headers)
log.info(resp.json())
log.info(resp.status_code)
Returns:
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 0ba03adb.ngrok.io
INFO:__main__:{'error': {'message': 'Required field Vendor not specified.', 'code': 'ExecuteOData'}}
INFO:__main__:400
```
API Server Log file says:
Executing the following query: INSERT INTO [BillExpenseItems] ([ExpenseLineId], [ExpenseAccountId], [ExpenseAmount]) VALUES (@1, @2, @3);1=21;2=6001;3=10.00
ExecuteOData: Required field Vendor not specified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment