0

I am working with a remote API which I don't have any documentation on and I need to send a GET request with a JSON payload which isn't sent in the original HTTP request, but seems to be sent right after.

This is done with the original Python tool using the following instruction:

urllib.request.Request(url=url, method='GET', data=bytes(json.dumps(data), 'utf8'))

I have been looking through Wireshark to get more informations about it, and it appears the GET requests is composed of the HTTP request and the JSON object (both being distinct from one another):

Wireshark

My question would be: How can I achieve this using the cURL C library ? I have been looking at the manual for a while and it appears parameters cannot be passed like a POST request (CURLOPT_POSTFIELDS).

Ra'Jiska
  • 979
  • 2
  • 11
  • 23

1 Answers1

1

I finally found the solution to this issue.

My cURL request was done using the CURLOPT_HTTPGET option which could not be combined with the CURLOPT_POSTFIELD option. To fix this, I needed to replace it with the CURLOPT_CUSTOMREQUEST option allowing me to combine any request type to the CURLOPT_POSTFIELD option.

This post helped me: a raw libcurl JSON PUT request using C

Ra'Jiska
  • 979
  • 2
  • 11
  • 23