curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: character substitution

From: Daniel Stenberg via curl-users <curl-users_at_cool.haxx.se>
Date: Thu, 12 Aug 2021 23:22:39 +0200 (CEST)

On Thu, 12 Aug 2021, Peter Johnson via curl-users wrote:

> curl -k -G -b e:\exero\cmds\curl\bin\monsta
> https://nms.xxxxxxx.xxx/api/rest/command/device.update --data-urlencode
> "deviceserial=230059&devicename=Camera -WP 5FL FILE RM&tag1=IP
> Camera&tag2=IFS03CFOCWST&tag3=WP&tag4=WP 5FL FILE
> RM&tag5=us-ny-119&model=IFS03CFOCWST Network camera 07-29-2019
> Illustra.SS004.01.06.05.0026&vendor=illustra"

You're probably not using this right. (And this point of mine might be
completely irrelevant about the + problem.)

When you do --data-urlencode "name=content" curl will URL encode the entire
content. Your provided content contains ampersands (&) that look like they
separate different name=value pairs but in your command line, the ampersands
will be encoded to %26 so they will not work as separators in the receiving
server.

You *probably* rather want to provide the fields separately:

curl [...] --data-urlencode deviceserial=230059 \
  --data-urlencode devicename="Camera -WP 5FL FILE RM" \
  --data-urlencode tag1="IP Camera" ...

etc

Since when curl gets multiple data parts to send, it will concatendate them
separated with an ampersand (&).

An advice is to use the --trace-ascii option to double-check that the request
gets sent off exactly the way you intend.

-- 
  / daniel.haxx.se
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
  | https://curl.se/support.html
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2021-08-12