Solved

Adding a string to URL accessing someone else's API

Posted on 2012-03-12
5
337 Views
Last Modified: 2012-03-15
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!
0
Comment
Question by:ambientsbs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 37712228
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.
0
 

Author Comment

by:ambientsbs
ID: 37712241
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!
0
 
LVL 18

Accepted Solution

by:
nap0leon earned 500 total points
ID: 37714314
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!
0
 
LVL 25

Expert Comment

by:kevp75
ID: 37725297
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
0
 

Author Closing Comment

by:ambientsbs
ID: 37725508
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!
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question