question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.NullPointerException: Cannot get property 'assertionClosure' on null object

See original GitHub issue

I get this exception (java.lang.NullPointerException: Cannot get property ‘assertionClosure’ on null object) when using the RequestSpecificationBuilder as below and sending a request using POST method

//Elsehwere 
RequestSpecification r = RestAssured.given().relaxedHTTPSValidation().accept(ContentType.ANY)
                .auth().preemptive().basic(cslConsole.getloginUser(), cslConsole.getloginPassword())
                .baseUri(cslConsole.getManagementConsoleURL());
basicRequest.spec(r);

//At the point of sending the request
RequestSpecBuilder builder = new RequestSpecBuilder();
builder.addRequestSpecification(basicRequest);
builder.addQueryParam("param","50");
builder.setBasePath("/api/v1/scsr");
builder.setBody("Some body");
RequestSpecification request = reqSpecbuilder.build();
String url = "https://10.0.2.4:8443/"
Response response = request.post(url); ---->exception

Is this expected ? I do not see an issue with the RequestSpecBuilder .setBody() as I am using it with only POST? Any clues ?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

7reactions
icrossfield-bjsscommented, Jul 16, 2019

+1 `public CommonHelpers() { spec = builder.addHeader(“User-Agent”, USER_AGENT).build() .baseUri(BASE_URL) .contentType(ContentType.JSON);

} public static Response getEntities(Map<String, String> queryParams) { spec.basePath(BASE_PATH); Optional.ofNullable(queryParams).ifPresent(spec::parameters); return spec.when().get(); }`

The exception is raised at spec.when().get()

Pass your built RequestSpecification instance to the given method…

RestAssured.given(spec).get();

1reaction
johanhalebycommented, Dec 7, 2017

Yeah sounds like a bug 😦

On Wed, Dec 6, 2017 at 10:39 PM, dreamsivaraj notifications@github.com wrote:

Getting the same error on running the below code.

RequestSpecBuilder request = new RequestSpecBuilder(); request.setBaseUri(“https://google.com”); String str2 = request.build().when().get().asString(); System.out.println(str2);

Where as it working in the below code.

String str1 = given().baseUri(“https://google.com”).when().get().asString(); System.out.println(str1);

It should be a bug.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rest-assured/rest-assured/issues/938#issuecomment-349783462, or mute the thread https://github.com/notifications/unsubscribe-auth/AALalU-JeWkVyU7t_aZLRwyBWUKQC6G2ks5s9wmQgaJpZM4QSHkQ .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Null-pointer exception when invoking get in rest-assured
Try using RestAssured.given() to call your GET. You can use your requestSpec by doing something like this:
Read more >
Solved: How to fix "cannot get property 'info' on null obj...
When trying to create my first project by importing from my swagger (Apoen API 2.0) spec, it fails with "java.lang.NullPointerException: cannot ...
Read more >
Cannot get property 'assertionClosure' on null object
I get this exception (java.lang.NullPointerException: Cannot get property 'assertionClosure' on null object) when using the ...
Read more >
Nullpointer: Cannot get property 'stages' on null object
java.lang.NullPointerException: Cannot get property 'stages' on null object at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:60) at ...
Read more >
Cannot Get Property "Name" On Null Object - Oracle Support
My Oracle Support Banner. Cannot Get Property "Name" On Null Object (Doc ID 2636751.1). Last updated on JULY 01, 2021 ... Java.lang null...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found