esp32-course
esp32-course copied to clipboard
HTTP post request not returning valid data
Hi, I am trying to use this http client example but I am not able to visualize the data received, I am able to receive and parse JSON data on post request without header but when I add header , which is required for this one particular request the buffer shows no data , while param.message shows ?????? in terminal.
Following is my request format
`struct FetchParams dataStruct; dataStruct.OnDataRcv =OnDataRcv; dataStruct.method=Post; Header headerContentType = { .key="Content-Type", .val="Application/json"
};
Header headerAuth = {
.key="Authorization",
.val=(char *)my_authCode
//.val="Bearer 249174ddf663787f4ea605e5ef3c4996c03601543e5994a0d422adbe397c8d9e971560149708740"
};
dataStruct.header[0]=headerAuth;
dataStruct.header[1]=headerContentType;
char buffer[300];
requestBody(clientId,authToken,buffer);
dataStruct.body=buffer;
fetch("https://api.test.fyta-app.de/hub/auth",&dataStruct);`
I have checked with postman , it returns the following output data
{ "access_token": "170ea98ce3fb4f7fc0955a3277e5f0ab9c9d3abad59b435553d36f11b0c81b2b731618926240929", "token_type": "Bearer", "expires_in": 86400, "refresh_token": "17b52fd903fec46f884fa5a1431f30a7f5556663408b9a521bfa6437254731f4ec1618926240930", "scope": "hub" }
I am also attaching output on terminal,