Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basePath not getting configured properly. #872

Open
akshayamaldhure opened this issue Jun 9, 2017 · 4 comments
Open

basePath not getting configured properly. #872

akshayamaldhure opened this issue Jun 9, 2017 · 4 comments

Comments

@akshayamaldhure
Copy link

Working code:
response = given().setBasePath("basePath").headers("key","value").body("{ }").when().post("");

Non-working code (In this case, I get 405 error code from the server which is returned when basePath is not configured properly):
response = given().spec(setLogging()).spec(setConfig("basePath")).spec(addHeader("key", "value")).body("{ }").when().post("");

I'm configuring the baseUri in my TestNG Listener using RestAssured.baseURI = "baseUri" assignment in both above cases and it works correctly for the "working code" case. Below are the definition of the helper methods I've used in the non-working code above.

//helper method to enable HTTP method logging
public static RequestSpecification setLogging() {
return new RequestSpecBuilder().log(LogDetail.METHOD).build();
}

//helper methods to set baseURI/basePath 
public static RequestSpecification setConfig(String basePath) {
Log.info("API endpoint under test: "+basePath);
return new RequestSpecBuilder().setBasePath(basePath).setContentType(ContentType.JSON).build();
}

//helper methods to add request headers
public static RequestSpecification addHeader(String key, String value) {
Log.info("Header: "+key+" = "+value);
return new RequestSpecBuilder().addHeader(key, value).build();
}

PS: Could this be related to bug #871 in any way?

@akshayamaldhure
Copy link
Author

@johanhaleby Could you please assign and prioritise this issue?

@johanhaleby
Copy link
Collaborator

I'll deal with it when I find the time, no promises. (remember that this is an open source project that I'm maintaining on my spare time)

@akshayamaldhure
Copy link
Author

Of course @johanhaleby , I remember that. I commented on this issue and bug #871 too just in case you forgot to check these out. :)

@johanhaleby
Copy link
Collaborator

Great :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants