I'm trying to make a POST request for MethodAPIInsertV2 to the purchaseorder table. I get a response saying "Not all required fields are present. Required field TxnDate is not passed for the table purchaseorder"
I have included the TxnDate in the passed parameters. Here is my code...
#############################
d = date.today()
txnDate = str(d.strftime("%m/%d/%y"))
#Get authentication
file = open('config.txt', 'r')
companyAccount = file.readline()
username = file.readline()
password = file.readline()
txnID = '12345'
#POST request to method
url = 'http://www.methodintegration.com/MethodAPI/service.asmx/MethodAPIInsertV2'
headers = {'Host': 'www.methodintegration.com', 'Content-Type': 'application/x-www-form-urlencoded'}
parameters = {
'strCompanyAccount': companyAccount,
'strLogin': username,
'strPassword': password,
'strSessionID': '',
'strTable': 'purchaseorder',
'arrInsertFieldsArray': 'TxnDate',
'arrInsertFieldsArray': 'TxnID',
'arrInsertFieldsArray': 'VendorRef_FullName',
'arrInsertFieldsArray': 'Memo',
'arrInsertValueArray': txnDate,
'arrInsertValueArray': txnID,
'arrInsertValueArray': 'The Stow Company',
'arrInsertValueArray': customer
}
r = requests.post(url, headers=headers, data=parameters)
print(r.status_code, r.reason, r.text)
###############################