Actually, you can trim down the request a bit and keep it simple.

You don’t have to specify the content-length. It will be calculated automatically and appended to the headers.

Also, you don’t have to declare the request as a post request explicitly. If you are setting the POSTFIELDS option for curl, curl will convert the request type to POST.