Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

No creator found for com.gargoylesoftware.htmlunit.UnexpectedPage (JSON response) #19

Copy link
Copy link
@ashes999

Description

@ashes999
Issue body actions

I'm trying to write a functional test for an MVC5 + Web API project where I log in (via web forms), and then make a POST call directly to the API route. When I make the call to client.GetPage, I get an InvalidOperationException with this message: No creator found for com.gargoylesoftware.htmlunit.UnexpectedPage

This was reported against HtmlUnit itself on SO about five years ago.

var client = new WebClient(BrowserVersion.CHROME);
 var method = new HttpMethod(com.gargoylesoftware.htmlunit.HttpMethod.POST);
var json = JsonConvert.SerializeObject(inputObject);

var webRequest = new WebRequest(new java.net.URL("http://localhost/site/api/game"), new HttpMethod(method))
{
    RequestBody = "=" + json // WebAPI expects this. Don't ask me why.
};
var page = client.GetPage(webRequest);

I can see the call hit the server side (including the response object which comes back) -- it's not throwing an exception there, only on the client. The response is pure JSON:

{
    "Data": [
        {
            "Id": "00000000-0000-0000-0000-000000000000",
            "Name": "FT-FunctionalTestGame",
            "OwnerId": 3
        }
    ],
    "Errors": null
}
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.