posting data to an API

I’m working with a vendors API and the documentation is a little sparse. they are looking for a post formatted like this. {"import":{"members":[{"organization_customer_identifier":"XXXXXX","program_customer_identifier":"XXXXXX","member_customer_identifier":"XXX-XXX-XXXX","first_name":"Mister","last_name":"Tester","email_address":USER@DOMAIN.COM,"member_status":"OOOO","record_identifier":"XXX"}]}}’ my code is submitting it like this. {"members":{"organization_customer_identifier":"XXXXXX","program_customer_identifier":"XXXXXX","member_status":"OOOO","member_customer_identifier":"XXX-XXX-XXXX","first_name":"Mister","last_name":"Tester","email_address":"USER@DOMAIN.COM","record_identifier":"XXX"}} I’m not that versed in using PHP to submit to an API with json/curl… as i understand it "import" is object and "members" is… Read More posting data to an API

loop through list of jsons, curl it and save outputs

I have a list of jsons in a file input.dat like so (many are utf-8 encoded): {"var1": "laptop", "var2": "new", "var3": "ugly"} {"var1": "televison", "var2": "old", "var3": "bad"} {"var1": "cleaner", "var2": "used", "var3": "good"} {"var1": "Pakman", "var2": "sale", "var3": "thrones"} I have built an api which works with the following curl command: curl –header "Content-Type:… Read More loop through list of jsons, curl it and save outputs

curl parses my json object in –raw-data as its arguments

I’m trying to post data to an API using curl, I’m using this bash script: script.sh send_command () { echo "{\"cmd\":\"$@\"}" curl –request POST \ –data-raw "{\"cmd\":\"$@\"}" \ -H "Content-Type: application/json"\ "http://localhost:8080/addCmd/" } command_1 () { send_command test_command \ -I {{files1}} \ —files1 ‘my_file.txt’\ } after sourcing from script.sh then running command_1 in the terminal,… Read More curl parses my json object in –raw-data as its arguments

Can't run curl on ubuntu:latest docker image with some https urls – SSL: no alternative certificate subject name matches target host name

Today I found that curl stopped recognizing some SSL certificates as valid ones, despite the fact that firefox and wget are able to handle them properly as well as openssl’s s_client. In order to reproduce it: docker run -it ubuntu:latest /bin/bash And then in in-container bash: apt update && apt install curl ca-certificates -y -qq… Read More Can't run curl on ubuntu:latest docker image with some https urls – SSL: no alternative certificate subject name matches target host name

Problem with download file via CURL in PHP

I have a problem when i try download file with curl php. Headers response PHP Code $filePath = $this->exchangePath . $this->exchangeFile; $url = $this->exchangeURL; $fp = fopen($filePath, ‘w’); $ch = curl_init($url); curl_setopt($ch, CURLOPT_FILE, $fp); $data = curl_exec($ch); curl_close($ch); fclose($fp); Preview file data after downloading (106Kb) Preview file data on server (1.9 Mb – The file… Read More Problem with download file via CURL in PHP

cURL command not returning data or error messages

Figuring out a new API. I’m trying to call an endpoint and populate a JSON file with the data. I see the following output: admin@server:~$ curl -H "Authorization: Bearer <NOT DISPLAYED FOR THIS POST>" -o /home/admin/result.json https://www.endpoint.com/manage/query/run?id=55408&cmd=service&output=json [1] 14493 [2] 14494 admin@server:~$ % Total % Received % Xferd Average Speed Time Time Time Current Dload… Read More cURL command not returning data or error messages

use parameter in curl command

I have a parameter which is container and i want to use this parameter during run curl command. I use like below but it gives an error. Any idea about that? I use it in bash script. curl -X ‘GET’ ‘https://mycontainer/api/v2.0/projects/testproject/repositories/$(container)/artifacts?page=1&page_size=1&with_tag=true&with_label=false&with_scan_overview=false&with_signature=false&with_immutable_status=false&with_accessory=false&#8217; -H ‘accept: application/json’ -H ‘X-Accept-Vulnerabilities: application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0’ -H ‘authorization: Basic YWhtZXQuY2Fua2F5YUBucy5ubDo2MkVEbDIxUEM=’ |… Read More use parameter in curl command

How to use a "curl -X POST" command with query in PHP?

I want to use the command below: curl -X POST ‘https://graphcdn.frankenergie.nl/&#8217; -H ‘Content-Type: application/json’ -H ‘User-Agent: Integromat/production’ -d ‘{ "query": "query MarketPrices {\n\tmarketPricesElectricity(startDate: \"2023-01-12\", endDate: \"2023-01-15\") {\n till\n from\n marketPrice\n priceIncludingMarkup\n\t}\n\tmarketPricesGas(startDate: \"2023-01-11\", endDate: \"2023-01-11\") {\n from\n till\n marketPrice\n priceIncludingMarkup\n }\n}" }’ When I execute this command in the command line it works fine (result Now… Read More How to use a "curl -X POST" command with query in PHP?