xReidx
xReidx

Reputation: 3

QAF: API ERROR code 0x80072530 : Passed entity object cannot be null or empty

Implementing the NTLMAutClient is working with valid ntlm credentials. However, upon running the JSON request, the aforementioned error occurs.

Below is the JSON payload:

{
    "headers":
    {
        "Content-Type": "application/json"
    },
    
    "endPoint": "",
    "baseUrl": "${crm_base_url}/api/data/v9.1/contacts(mli_integrationkey='CAS-${clientNumber}')",
    "method": "PATCH",
    
    "body":
    {
        "mli_mcfuserid": ""
    }
}

And here is the response from the QMetry report:

Request

Client out-bound request PATCH https://baseurl.com/CRM/api/data/v9.1/contacts(mli_integrationkey='CAS-1234567890') Content-Type: application/json {"mli_mcfuserid":""}

Response

Client in-bound response 400 Cache-Control: no-cache Allow: OPTIONS,GET,HEAD,POST Content-Type: application/json; odata.metadata=minimal Expires: -1 Server: x-ms-service-request-id: 8e609396-690e-44f4-8d9a-2cf2d423856e Strict-Transport-Security: max-age=31536000; includeSubDomains REQ_ID: 8e609396-690e-44f4-8d9a-2cf2d423856e REQ_ID: 8e609396-690e-44f4-8d9a-2cf2d423856e Set-Cookie: ReqClientId=20330979-0d93-47d0-bd2b-0313bef1fb24; expires=Fri, 19-Jan-2074 10:46:11 GMT; path=/; secure; HttpOnly Set-Cookie: orgId=f1983a41-2ae6-e811-8120-0050568b693f; expires=Fri, 19-Jan-2074 10:46:11 GMT; path=/; secure; HttpOnly OData-Version: 4.0 Persistent-Auth: true Public: OPTIONS,GET,HEAD,POST Timing-Allow-Origin: * Date: Fri, 19 Jan 2024 10:46:10 GMT Content-Length: 89

{
    "error": {
        "code": "0x80072530",
        "message": "Passed entity object cannot be null or empty."
    }
}

Already tried a lot of debugging like updating the qaf-support-ws version, using different ntlm credentials (with and without the ntlm.workstation and ntlm.domain), trying different headers combinations, etc., but still stuck with the error.

[UPDATE] Below is the method we use to read and execute .json payload files:

JSONParser jsonParser = new JSONParser();
    File file = new File(path);
    Object data = jsonParser.parse(new FileReader(file));
    JsonObject jsonObject = new Gson().toJsonTree(data).getAsJsonObject();
    HashMap<String, Object> result;
    
    try {
        result = new ObjectMapper().readValue(jsonObject.toString(), HashMap.class);
        RestRequestBean bean = new RestRequestBean();
        bean.fillData(jsonObject.toString());
        bean.resolveParameters(result);
        return WsStep.request(bean);
    } catch (JsonParseException e) {
        logger.info("JsonParseException: ", e);
    } catch (JsonMappingException f) {
        logger.info("JsonParseException: ", f);
    } catch (IOException g) {
        logger.info("JsonParseException: ", g);
    }

Dependencies version:

qaf: 3.0.0

qaf-support-ws: 2.1.13

quantum-version: 1.23.0

Upvotes: 0

Views: 181

Answers (1)

user861594
user861594

Reputation: 5908

If body is json you still need to quote it. For example:

"body": "{ \"mli_mcfuserid\": \"\"}" 

You also can use repository editor to avid syntax issues and to manually try before using request call in automation. For web service calls, if your file has .properties extension, change it to .wsc and you will be able to create/edit/execute through ui.

Upvotes: 0

Related Questions