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

Query string in the URL fails with Route error #55

Closed
joshuataylor opened this issue Nov 26, 2017 · 2 comments
Closed

Query string in the URL fails with Route error #55

joshuataylor opened this issue Nov 26, 2017 · 2 comments

Comments

@joshuataylor
Copy link

If testing a URL like /foo.json?bar=baz&doo=1 this fails with:

** (exit) an exception was raised:
    ** (RuntimeError) Route error
        (bypass) lib/bypass/plug.ex:24: Bypass.Plug.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

However just /foo.json will work.

@joshuataylor joshuataylor changed the title Query string fails Query string fails with Route error Nov 26, 2017
@joshuataylor joshuataylor changed the title Query string fails with Route error Query string in the URL fails with Route error Nov 26, 2017
@chulkilee
Copy link

bypass accepts "path", not with query string. See https://github.com/PSPDFKit-labs/bypass/blob/v0.8.1/lib/bypass.ex#L111

from https://github.com/chulkilee/ex_force/blob/v0.1.0/test/ex_force_test.exs#L241

  test "get_sobject with fields", %{bypass: bypass} do
    Bypass.expect_once(bypass, "GET", "/services/data/v40.0/sobjects/Account/foo", fn conn ->
      %{"fields" => "Name,Site"} = URI.decode_query(conn.query_string)

      resp_body = """
      {
        "attributes": {
          "type": "Account",
          "url": "/services/data/v40.0/sobjects/Account/foo"
        },
        "Id": "foo",
        "Name": "name",
        "Site": null
      }
      """

      conn
      |> Conn.put_resp_content_type("application/json")
      |> Conn.resp(200, resp_body)
    end)

    {:ok, got} = ExForce.get_sobject("foo", "Account", ["Name", "Site"], dummy_config(bypass))

    assert got == %SObject{
             id: "foo",
             type: "Account",
             data: %{"Id" => "foo", "Name" => "name", "Site" => nil}
           }
end

@hernanvicente
Copy link

@chulkilee, your solution worked for me! It should be part of the README or documentation.

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

3 participants