When trying to convert the response into map<string>, the following error is encountered:
time=2024-10-23T10:11:44.446+05:30 level=ERROR module=ballerina/http message="unhandled error returned from the service" error={"causes":[{"message":"Error occurred while extracting json data from entity: error("unrecognized token 'access_token=******&expires_in=28800&refresh_token=******&refresh_token_expires_in=15724800&scope=&token_type=bearer' at line: 1 column: 226")","detail":{},"stackTrace":[{"callableName":"externGetJson","moduleName":"ballerina.http.2","fileName":"http_commons.bal","lineNumber":373},{"callableName":"getJsonPayload","moduleName":"ballerina.http.2.Response","fileName":"http_response.bal","lineNumber":212},{"callableName":"nonNilablejsonPayloadBuilder","moduleName":"ballerina.http.2","fileName":"http_client_payload_builder.bal","lineNumber":163},{"callableName":"jsonPayloadBuilder","moduleName":"ballerina.http.2","fileName":"http_client_payload_builder.bal","lineNumber":139},{"callableName":"getBuilderFromType","moduleName":"ballerina.http.2","fileName":"http_client_payload_builder.bal","lineNumber":69},{"callableName":"performDataBinding","moduleName":"ballerina.http.2","fileName":"http_client_payload_builder.bal","lineNumber":43},{"callableName":"processResponse","moduleName":"ballerina.http.2","fileName":"http_client_endpoint.bal","lineNumber":743},{"callableName":"processPost","moduleName":"ballerina.http.2.Client","fileName":"http_client_endpoint.bal","lineNumber":98}]}],"message":"Error occurred while retrieving the json payload from the response","detail":{},"stackTrace":[{"callableName":"getJsonPayload","moduleName":"ballerina.http.2.Response","fileName":"http_response.bal","lineNumber":218},{"callableName":"nonNilablejsonPayloadBuilder","moduleName":"ballerina.http.2","fileName":"http_client_payload_builder.bal","lineNumber":163},{"callableName":"jsonPayloadBuilder","moduleName":"ballerina.http.2","fileName":"http_client_payload_builder.bal","lineNumber":139},{"callableName":"getBuilderFromType","moduleName":"ballerina.http.2","fileName":"http_client_payload_builder.bal","lineNumber":69},{"callableName":"performDataBinding","moduleName":"ballerina.http.2","fileName":"http_client_payload_builder.bal","lineNumber":43},{"callableName":"processResponse","moduleName":"ballerina.http.2","fileName":"http_client_endpoint.bal","lineNumber":743},{"callableName":"processPost","moduleName":"ballerina.http.2.Client","fileName":"http_client_endpoint.bal","lineNumber":98}]} path="/auth2?code=96bed644eace827d42c6" method="POST"
Steps to Reproduce
Service:
import ballerina/http;
import ballerina/mime;
service /api on new http:Listener(9090) {
resource function get path() returns http:Response {
http:Response res = new;
string payload = "access_token=ashgdfoiutsfubxcwfe7263duwhc8yw9ien2c&expires_in=28800&refresh_token=whdsgyf2tec780u2bu3d8x2i2bydhxi2ef9i2f&refresh_token_expires_in=15724800&scope=&token_type=bearer";
res.setPayload(payload, mime:APPLICATION_FORM_URLENCODED + "; charset=utf-8");
return res;
}
}
Client:
import ballerina/http;
import ballerina/io;
public function main() returns error? {
http:Client clientEP = check new ("localhost:9090/api");
map<string> res = check clientEP->/path;
io:println(res);
}
Version
Ballerina SwanLake Update 10(2201.10.0) and HTTP Package version - 2.12.2
Description
The content type of the header of an http response is:
application/x-www-form-urlencoded; charset=utf-8
.Below is the sample payload recieved:
When trying to convert the response into
map<string>
, the following error is encountered:Steps to Reproduce
Service:
Client:
Version
Ballerina SwanLake Update 10(2201.10.0) and HTTP Package version - 2.12.2