KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: LAUNCH EXTERNAL PROCESS with curl defaults to Command Prompt instead of Powershell
PRODUCT: 4D | VERSION: 20 | PLATFORM: Win
Published On: December 11, 2023

When using curl with LAUNCH EXTERNAL PROCESS, note that command prompt will be the default executable instead of Powershell. This is an important aspect as some curl syntax may be acceptable in Powershell, but not in Command prompt. Take an example where the curl command below is ran in Powershell:

curl.exe -X POST 'http://localhost/test' -H 'Content-Type: application/json' -d '{"a":"b"}'

In this case, Powershell will accept the syntax. When running the same example in Command Prompt, the single quotes will not be accepted, the URL will be rejected, and there may be issues parsing the double quotes within objects. To resolve this, change all single quotes around the curl parameters to double quotes and change all double quotes within the passed object to escaped double quotes using the backslash like so:

curl.exe -X POST "http://localhost/test" -H "Content-Type: application/json" -d "{\"a\":\"b\"}"

Now when the file containing the above curl command is read and passed into LAUNCH EXTERNAL PROCESS, it should hit 4D's On Web Connection properly and the passed object should be able to JSON Parse correctly with the escaped double quotes.