When trying to convert the response into map, the following error is encountered:
Error
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"
Code:
resource function post auth2(string code) returns error? {
io:println("Code: ", code);
http:Client copilotAuthClient = check new ("https://github.com");
map<string> response = check copilotAuthClient->post(string `/login/oauth/access_token?
client_id=${clientId}&client_secret=${clientSecret}&code=${code}`,"The auth2 endpoint is successful");
}
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:
access_token=*&expires_in=28800&refresh_token=*****&refresh_token_expires_in=15724800&scope=&token_type=bearer
When trying to convert the response into map, the following error is encountered:
Error
Code:
Steps to Reproduce
$subject
Version
ballerina version: 10.0
Environment Details (with versions)
No response