MDES SDK Guides How to handle output results

wa_api_invoke invocations return an error code and populate a JSON formatted wa_wchar pointer that is passed as a json_out parameter. The content of this JSON formatted wa_wchar pointer will be dependent on the success/failure error code returned.

Regardless of the success or failure of the wa_api_invoke, you must pass the json_out allocated pointer to wa_api_free to release the allocated memory back to the process.

Successful call

If this functions returns a successful error code the json_out will be populated with the following:

 {
        "result" : {
                "method" : number,
                "code" : number,
                "timing" : number,
                "timestamp" : string,
                "result" : object
        }
 }

Failed call

If this functions returns a failure error code the json_out will be populated with error information:

 {
        "error": {
                "code" : number,
                "method" : number,
                "errors" : [            
                        {
                                "code" : number,
                                "method" : string,
                                "called_at" : string,
                                "returned_at" : string,
                                "message" : string,
                                "errors" : array
                        },
                        ...
                ],
                "description" : string,
                "define" : string,
                "timing" : number
                "timestamp" : string
        }	
 }

Setup call

This is the expected return from a wa_api_setup call. Each deployed module can return a different configuration object with keys that may only exist for that module. Only the guaranteed keys are shown here.

 {
        "errors" : [            
                {
                        "module" : string,
                        "code" : number
                },
                ...
        ],
        "configs" : [
                {
                        "timing" : number,
                        "module" : string,
                        ...
                },
                ...
        ]
 }