API Response
[Data:[DuplicateInvoiceReference:null, RequestID:null], Error:[[Code:API.INV.005, Description:Invoice Reference is null or empty]],
Status:3, Warning:null]
I'm going to asset the Error Object, below is my code
def responseData = jsonSlurper.parseText(responseBody)
assert responseData.Error.Description == "Invoice Reference is null or empty"
but I received assertion failed
assert responseData.Error.Description == "Invoice Reference is null or empty"
| | | |
| | | false
| | [Invoice Reference is null or empty]
| [[Code:API.INV.005, Description:Invoice Reference is null or empty]]
[Data:[DuplicateInvoiceReference:null, RequestID:null], Error:[[Code:API.INV.005, Description:Invoice Reference is null or empty]], Status:3, Warning:null]
Please clarify the issues in the assertion part?
You're reading Description
as though Error
were a map. It is a list.
You should be having
assert responseData.Error[0].Description == "Invoice Reference is null or empty"
You need to read Description
off the first element of responseData.Error
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.