tesla
tesla copied to clipboard
Json decoding
I'm having an issue with the json decoding, in the tests Tesla isn't giving back a json, but a string. This is the logging result:
<<< RESPONSE <<<
content-type: application/json
"
{:ok,
%Tesla.Env{
__client__: nil,
__module__: nil,
body: "{\n \"success\": true,\n \"listing\": {\n \"ticketId\": 123,\n \"productionId\": 123,\n \"id\": 123\n }\n}\n",
headers: [{"content-type", "application/json"}],
method: nil,
opts: [],
query: [],
status: 200,
url: ""
}}
The request is a POST request with the following headers:
>>> REQUEST >>>
(no query)
api-token: ***
content-type: application/json
and this is how the client is built:
headers = [{"api-token", "#{api_token}"}]
Tesla.client([
{Tesla.Middleware.BaseUrl, @base_url},
{Tesla.Middleware.Retry, [
delay: 500,
max_retries: 2,
max_delay: 10_000,
should_retry: &some_fun/1]},
{Tesla.Middleware.Headers, headers},
Tesla.Middleware.JSON,
Tesla.Middleware.Telemetry,
Tesla.Middleware.KeepRequest,
{Tesla.Middleware.Logger, account: account, additional_logs: additional_logs}
])
Jason is listed in the dependencies.
Is this library still supported? I tried to clean and recompile tesla, but to no avail. Also, there isn't any indication in the compilation process telling me that it works.
Also, when I put exactly {:jason, ">= 1.0"}
in deps
, mix gives an error
Did you find a solution? I seem to have the same problem, and am unsure if I'm using it wrong.
Piping the response body into Jason.decode works fine.
@MeerKatDev @Straffern Can you provide an executable example?
Hey peeps, could you provide some example repo reproducing the bug?
Sorry, only the code above. I don't have that codebase anymore.
Hey there, I tried it, but I didn't get anywhere.
Please provide some complete example codes on how to reproduce the issue since it is really hard to asses fully what is going on.
Feel free to reopen the issue if the error persists.