Method Community

 

Not all required fields are present

Last post 08-27-2018 12:11 PM by scarson. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 08-14-2018 4:53 PM

    Not all required fields are present

    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)

    ###############################

  • 08-15-2018 9:18 AM In reply to

    Re: Not all required fields are present

    Our API is currently based on SOAP web service specification. You would typically use requests library to talk to REST API. For SOAP services in Python we suggest using libraries such as zeep. Please let us know if you need help implementing your API call with zeep.

    Best Regards,

    Hossein Riazi

  • 08-16-2018 1:07 PM In reply to

    Re: Not all required fields are present

    Okay, I don't have any experience with SOAP API's. This is my attempt at using zeep, but I get the same error for the "VendorRef" this time. Do you have an example by chance? Thanks for the help!

    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'

    fields = ['TxnDate', 'TxnID', 'VendorRef', 'Memo']
    values = [txnDate, txnID, 'The Stow Company', customer]

    parameters = {
    'strCompanyAccount': companyAccount,
    'strLogin': username,
    'strPassword': password,
    'strSessionID': '',
    'strTable': 'purchaseorder',
    'arrInsertFieldsArray': fields,
    'arrInsertValueArray': values
    }

    client = Client('https://www.methodintegration.com/MethodAPI/service.asmx?WSDL')
    response = client.service.MethodAPIInsertV2(**parameters)

    print(response)

  • 08-16-2018 3:18 PM In reply to

    Re: Not all required fields are present

    To send array with zeep you need to do something similar to this:

    factory = client.type_factory('ns0')
    arr_names = factory.ArrayOfString(fields)
    arr_values = factory.ArrayOfString(values)
    parameters = {
    'strCompanyAccount': companyAccount,
    'strLogin': username,
    'strPassword': password,
    'strSessionID': '',
    'strTable': 'purchaseorder',
    'arrInsertFieldsArray': arr_fields,
    'arrInsertValueArray': arr_values
    }

    Let us know if you still have an issue.

    Regards,
    Hossein
  • 08-27-2018 12:11 PM In reply to

    Re: Not all required fields are present

    This worked for me when trying to use insertV2 on the purchaseorder table, but when trying to insert into the purchaseorderline table I keep getting the error message "There was an error in MethodAPIinsertV2".

    Here are the fields I'm trying to pass.


    fields.append('Item')
    fields.append('PurchaseOrderRecordID')
    fields.append('Rate')
    fields.append('Quantity')
    values.append(part.itemID)
    values.append(recordID)
    values.append(rate)
    values.append(part.quantity)

    arrNames = [
    arrValues = [
    arrNames = factory.ArrayOfString(fields)
    arrValues = factory.ArrayOfString(values)

    parameters = {
    'strCompanyAccount': companyAccount,
    'strLogin': username,
    'strPassword': password,
    'strSessionID': '',
    'strTable': 'purchaseorderline',
    'arrInsertFieldsArray': arrNames,
    'arrInsertValueArray': arrValues
    }


Page 1 of 1 (5 items)