Issue
I have this code
POST /account/p_api/v1/account/authorization/assign HTTP/1.1
Host: exemple.com
Cookie: exemle-locale=en;
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/json
Content-Length: 17
Origin: https://exemple.com
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Te: trailers
Connection: close
{"code":"herecode"}
I want to use curl and php to be able to send the request and add another code to "herecode"
I don't know how to do this
Solution
In your Browser open the developer tools
Go to the url in your Browser.
Go to the "Network Tab"
Right click the first request in the Network Tab
Select copy => curl
Go to https://curlconverter.com/php/
Paste the "curl copy"
And you have your PHP code.
There is a bug in their CURLOPT_HTTPHEADER
you need to make your own header array.
Example header:
'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8',
Change to
'Content-Type: application/x-www-form-urlencoded; charset=UTF-8',
Firefox curl copy example:
Chrome curl copy example:
Paste to urlconverter: This is a curl copy and paste for this page. curl php post request
Answered By - Misunderstood Answer Checked By - Pedro (WPSolving Volunteer)