I am trying to send an API request to the endpoint, and it is successful via Postman raw JSON, Now I am implementing the same in Laravel with HTTP facade.
Below is a POSTMAN screenshot with the successful response from the endpoint.
Now in Laravel I am struggling to send request, I tried below code, but yes, it shows unexpected {
$response = Http::withBody(jData={"apkversion": "1.0.0",
"uid": "dsfee3",
"pwd": "deeddee",
"factor2": "680208",
"vc":"eefsdf",
"appkey":"wefdsesdfd334",
"imei": "abc1234",
"source": "API"
})->post('https://api.shoonya.com/NorenWClientTP/QuickAuth');
How can I send a request with given parameters as raw JSON?
2
Answers
It was resolved by using below code...
When using the
Http::withBody()
you need to provide the body as astring
and specify the content type. However, for sending JSON data, it’s more common to use theHttp::post()
with->body()
or->json()
to automatically handle the JSON encoding and set the appropriate headers.