Global API
Response
5 min
response is the information returned from the request call this will be returned in the form of a map\<string, object> below is the list of keys or parameters returned in the response map 213,213,213 unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type error 213,213,213 unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type errors before requesting xero errors that occur while validating the request, or while making a request to xero are returned as ‘apierrors’ in the response after requesting xero errors occurred within xero while processing the request, or while processing the data in breadwinner are sent as ‘errors’ in the responsejson key of the response map examples breadwinner does validation prior to calling out to xero invalid request { action=readcustomer, apierrors={"errors" \[ {"message" "breadwinner was unable to process the request as the version parameter was not valid ", "code" "invalid version" } ] }, timestamp=1635186915365, validrequest=false, version=1 1 } the errors that xero returns will be included as "errors"in the "responsejson" below is the example that was reformatted for easier reading 400 { action=createcustomer, responsejson={ "customers" null, "errors" \[ { "message" "please enter value(s) for display name", "code" "user error" } ], "statuscode" "400" }, timestamp=1635239587001, validrequest=true, version=1 0 } sample structure on how to parse the response if(respmap containskey('apierrors') && respmap get('apierrors')!=null){ // add any custom apex code } else if(respmap containskey('responsejson') && string isnotblank((string)respmap get('responsejson'))){ // parse it to map or optionally to a wrapper map\<string,object> invoiceresponsejsonmap = (map\<string,object>)json deserializeuntyped((string)respmap get('responsejson')); if(invoiceresponsejsonmap != null && invoiceresponsejsonmap containskey('statuscode') && invoiceresponsejsonmap get('statuscode')!=null){ // add any custom apex code } if(invoiceresponsejsonmap != null && invoiceresponsejsonmap containskey('invoices') && invoiceresponsejsonmap get('invoices')!=null){ // parse it to object or optionally to a wrapper list\<object> soobj = (list\<object>)invoiceresponsejsonmap get('invoices'); map\<string,object> savedso = (map\<string,object>)soobj\[0]; // now we are inside the success case, please add your update field (dml) apex code here } if(invoiceresponsejsonmap != null && invoiceresponsejsonmap containskey('errors') && invoiceresponsejsonmap get('errors')!=null){ // add any custom apex code } }

