- Mark as New
- Bookmark
- Subscribe
- Permalink
- Email to a Friend
- Report Inappropriate Content
Missing required value: Type
Hi Guys
I am battling to programmatically create a new payment using this library hosted on GitHub: https://github.com/bolaurent/zuora_restful_python/blob/master/README.md
After creating a valid connection to the sandbox, the code which I have is as follows:
zuora = Zuora(username, password, endpoint='sandbox')
accountDetails = zuora.query_all('select Name from Account')
for record in accountDetails:
print(record)
payment = {
"accountId": "2c92c0f85b7a6fc4015b805b29e52ed4",
"amount": 44.1,
"comment": "Comment",
"currency": "ZAR",
"effectiveDate": "2017-05-30",
"type": "External",
"paymentMethodId": "2c92c0f957f5653c0157f91b39d30030",
"referenceId": "102715845"
}
newPayment = zuora.create_payment(payment);
print(newPayment);
The result is as follows:
Traceback (most recent call last):
File "test.py", line 28, in <module>
newPayment = zuora.create_payment(payment);
File "build\bdist.win-amd64\egg\zuora_restful_python\zuora.py", line 331, in create_payment
File "build\bdist.win-amd64\egg\zuora_restful_python\zuora.py", line 206, in create_object
File "build\bdist.win-amd64\egg\zuora_restful_python\zuora.py", line 61, in _post
File "build\bdist.win-amd64\egg\zuora_restful_python\zuora.py", line 23, in _unpack_response
AssertionError: POST to /object/payment/ failed: {"Errors":[{"Code":"MISSING_REQUIRED_VALUE","Message":"Missing required value: Type"}],"Success":false}
What could I possibly be doing wrong here?
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Email to a Friend
- Report Inappropriate Content
Re: Missing required value: Type
Hi @darrenbilse,
Could you try making the payment object field names capitalized?
payment = { "AccountId": "2c92c0f85b7a6fc4015b805b29e52ed4", "Amount": 44.1, "Comment": "Comment", "Currency": "ZAR", "EffectiveDate": "2017-05-30", "Type": "External", "PaymentMethodId": "2c92c0f957f5653c0157f91b39d30030", "ReferenceId": "102715845" }
I think because it is a /object call, the field names have to match the old SOAP ones, and are case-sensitive.
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Email to a Friend
- Report Inappropriate Content
Re: Missing required value: Type
Here is some code that I wrote today, and which worked.
I concur that you should capitalize the keywords (in this API call, but not certain others!) The Zuora API seems to be remarkably inconsistent.
See my comment at https://community.zuora.com/t5/Admin-Settings-Ideas/REST-API-response-bug-quot-Success-quot-vs-quot-... (and vote it up!)
payment = { 'AccountId': zaccount['Id'], 'Amount': invoice['Balance'], 'EffectiveDate': opp['CloseDate'], 'PaymentMethodId': zuora.get_payment_method('Other'), 'Type': 'External', 'Status': 'Processed', 'InvoiceId': invoice['Id'], 'AppliedInvoiceAmount': invoice['Balance'] } zuora.create_payment(payment)
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Email to a Friend
- Report Inappropriate Content
Re: Missing required value: Type
Also, if you are using my library, please install new version; I've been fixing some bugs today.
Something like this:
pip3 install --upgrade git+git://github.com/bolaurent/zuora_restful_python