- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
12-26-2013 02:25 AM
Hi, colleagues!
I have a "Custom URL Category" and I try to add new URL from API request but if URL have ampersand(&) I have a error: <response status="error" code="18"><msg><line>Malformed Request</line></msg></response>
PanOS: 5.0.8
Original URL: example.com/proxy/index.php?hl=1111101001&q=789
My API request: https://HOST-IP/api/?type=config&action=set&key=API-KEY&xpath=/config/devices/entry[@name='localhost...<list><member>example.com/proxy/index.php?hl=1111101001&q=789</member></list>
If I add this URL manual I have't error, all OK, after that I look configuration in XML format and my URL looks like example.com/proxy/index.php?hl=1111101001&q=789 -- in XML if you need use & you must use &
OK! I change my API request: https://HOST-IP/api/?type=config&action=set&key=API-KEY&xpath=/config/devices/entry[@name='localhost...<list><member>example.com/proxy/index.php?hl=1111101001&q=789</member></list>
but no different
Anybody know how resolve this problem ?
P.S.: sorry for my english.
12-26-2013 02:48 AM
Hi,
Have you try something like:
Creating a new custom URL category:
http(s)://hostname/api/?type=config&action=set&xpath=/config/devices/entry/vsys/entry[@name='vsys1']/pro
files/custom-url-category/entry[@name='xmltest urlcat']&element=<description>testing xml
api</description><list><member>www.somesite.com</member></list>
Adding a URL to a custom URL category:
http(s)://hostname/api/?type=config&action=set&xpath=/config/devices/entry/vsys/entry[@name='vsys1']/pro
files/custom-url-category/entry[@name='xmltest
urlcat']/list&element=<list><member>www.somesite.com</member></list>
Adding an address object:
http(s)://hostname/api/?type=config&action=set&xpath=/config/devices/entry/vsys/entry[@name='vsys1']/add
ress/entry[@name='xmltest addr']&element=<ip-netmask>1.2.3.4/32</ip-netmask><description>xml
testing</description>
Hope help.
v.
12-26-2013 03:00 AM
Hi!
Thank you for answer.
I try this... but I have problem if URL contain &, if I delete this symbol from URL -- all OK.
I try use & instead & of but no results.
12-26-2013 03:16 AM
Hi,
Have you try to encode the "&" in utf ? use & in your request.
Let us know.
v.
12-26-2013 03:30 AM
All my trying and results(I am using cURL).
URL: example.com/proxy/index.php?hl=1111101001&q=789
> GET /api/?type=config&action=set&key=APIKEY&xpath=/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/profiles/custom-url-category/entry[@name='FEDERAL-LOW']&element=<list><member>example.com/proxy/index.php?hl=1111101001& HTTP/1.1
> User-Agent: curl/7.26.0
> Host: 172.16.1.164
> Accept: */*
> Content-Type: application/xml; charset=UTF-8
##########
URL: example.com/proxy/index.php?hl=1111101001&q=789
> GET /api/?type=config&action=set&key=APIKEY&xpath=/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/profiles/custom-url-category/entry[@name='FEDERAL-LOW']&element=<list><member>example.com/proxy/index.php?hl=1111101001&q=789</member></list> HTTP/1.1
> User-Agent: curl/7.26.0
> Host: 172.16.1.164
> Accept: */*
> Content-Type: application/xml; charset=UTF-8
##########
URL: example.com/proxy/index.php?hl=1111101001&q=789
> GET /api/?type=config&action=set&key=APIKEY&xpath=/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/profiles/custom-url-category/entry[@name='FEDERAL-LOW']&element=<list><member>example.com/proxy/index.php?hl=1111101001&q=789</member></list> HTTP/1.1
> User-Agent: curl/7.26.0
> Host: 172.16.1.164
> Accept: */*
> Content-Type: application/xml; charset=UTF-8
Response from PaloAlto:
<response status="error" code="18"><msg><line>Malformed Request</line></msg></response>
01-06-2014 12:40 AM
I think this is a current limitation of API as GUI accepts URL which contains "&". But I believe we don't usually include URL parameters (e.g. "?hl=1111101001&q=789") in Custom URL Category setting because the URL parameter value dynamically changes and URL Category should not change depending on the parameter.
If you want to allow / block http request depending on the URL parameters, I guess it would be better if it's done on the server side.
- Yasu
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!