rest-assured / rest-assured

Java DSL for easy testing of REST services
Apache License 2.0
6.85k stars 1.88k forks source link

Unable to convert xml to Json when use OData with &format=json and get two responses with one request #936

Open tobecrazy opened 7 years ago

tobecrazy commented 7 years ago

Use postman:
Get: https://localhost/odata/v2/signForm?formDataId=1000000L&$format=json Response json format: { "error": { "code": "TWF_INCORRECT_PARAMETER_ERROR", "message": { "lang": "en-US", "value": "No form found for cgrant1: 1000000." } } }

Code:

String host = "https://localhost";

@Test(enabled = true)
public void getTest1() {
    RestAssured.baseURI = host;

    Response result = RestAssured.given().auth().basic("cgrant@atTFTV1201", "pwd").contentType("application/json")
            .param("format", "json").param("formDataId", "1000000L").header("Content-Type", "application/json")
            .get("/odata/v2/signForm");
    // Assert.assertEquals(result.getStatusCode(), 200);
    System.out.println("Test1 >>>>>" + result.getBody().asString());
    System.out.println("Test1 <<<<<<<" + result.xmlPath().get("feed.title").toString());

}

But get below response

Test1 >>>>><?xml version="1.0" encoding="utf-8"?>TWF_INCORRECT_PARAMETER_ERRORNo form found for cgrant1: 1000000. Test1 <<<<<<< Test1 >>>>><?xml version="1.0" encoding="utf-8"?>TWF_INCORRECT_PARAMETER_ERRORNo form found for cgrant1: 1000000. Test1 <<<<<<<

johanhaleby commented 7 years ago

Hmm could you show the log if you do you result.prettyPeek()?

tobecrazy commented 7 years ago

Post man: { "error": { "code": "COE_FUNCTION_IMPORT_NOT_FOUND", "message": { "lang": "en-US", "value": "[COE0008]invalid function import name: Permission to access PM form, 360 form, Compensation or Recruiting Management are required, please make sure the feature is enabled and the user has access permission" } } } Rest-assured: RemoteTestNG] detected TestNG version 6.11.0 HTTP/1.1 400 Bad Request Date: Sun, 29 Oct 2017 03:00:58 GMT Server: Apache Strict-Transport-Security: max-age=16070400 OPTR_CXT: 01000100006389648c-bc55-11e7-97f1-1568e29dad1d00000000-0000-0000-0000-000000000001-1 HTTP ; Set-Cookie: JSESSIONID=F0037AB8E802709BC55BBD83BEAB56A2.pc15bsfapi51t; Path=/; Secure Event_ID: EVENT-UNKNOWN-UNKNOWN-pc15bsfapi51t.sha.sf.priv-20171029110058-143581 CorrelationId: e2f09434-308c-4266-ba64-42f89e848cc4 RequestNo: [136010] X-CSRF-Token: TwAzvcpFjB7lFpWOsgR9s5kaDY0%3d Company-Id: atTFTOAV1101 DataServiceVersion: 1.0 Error-Code: COE0008 SFODataServerTimeZone: Asia/Shanghai Content-Length: 403 Cache-Control: no-store X-Cnection: close Content-Type: application/xml;charset=utf-8 Set-Cookie: BIGipServerP_API15.XXXZSF.CN-80=1947471626.20480.0000; path=/; Httponly; Secure

COE_FUNCTION_IMPORT_NOT_FOUND [COE0008]invalid function import name: Permission to access PM form, 360 form, Compensation or Recruiting Management are required, please make sure the feature is enabled and the user has access permission

Test1 >>>>><?xml version="1.0" encoding="utf-8"?>COE_FUNCTION_IMPORT_NOT_FOUND[COE0008]invalid function import name: Permission to access PM form, 360 form, Compensation or Recruiting Management are required, please make sure the feature is enabled and the user has access permission

tobecrazy commented 6 years ago

Hi ,

@johanhaleby Any update for this ?