We help IT Professionals succeed at work.

Adding a string to URL accessing someone else's API

ambientsbs
ambientsbs asked
on
Hello Experts,

I'm currently using a search API provided by another website where I can add parameters in my URL string in order to return certain results in an XML file.

Right now, my URL string looks like such:

api.mydomain.com/search?source=CRAIG&category=VAUT&authID=<my authorization id>


This returns a very large xml file worth of data. One of the pieces of data that is returned in my XML is subcategory_2 = "cars & trucks - by owner". How would I go about adding that to my URL to filter my results by it. Basically, what I'm looking for is the equivalent to:

api.mydomain.com/search?source=CRAIG&category=VAUT&subcategory_2=cars+&+trucks+-+by+owner&authid=<my authorization id>.

Obviously, my URL doesn't work correctly, but if someone can tell me how to accomplish what I'm showing above properly that would be awesome!
Comment
Watch Question

Most Valuable Expert 2011
Top Expert 2016

Commented:
You should ask the provider of the API for instructions on how to use the API.  Any answer we give you here would be at best a guess.

Author

Commented:
I've reached out to them and didn't get a response yet. Just thought I would ask how to put

"cars & trucks - by owner"

into a search string. Can you tell me what the syntax would be to do that traditionally? I believe that will work for what I'm looking for. Thanks!
Top Expert 2011
Commented:
URL encoded, "cars & trucks - by owner"
is "cars%20%26%20trucks%20-%20by%20owner"

[space] = %20
& = %26

You'll really need to see their full API doc to even know if you can search by subcategory2.  Good luck!

Commented:
Yes, you are at their mercy at best.

At worst, get the entire XML as you are currently doing, end then search that for the string you need

Author

Commented:
This was pretty close to what I needed.....I used "cars+%26+trucks+-+by+owner" and got the results I needed. Thanks for your help!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.