c# - Error 404 from Google Search API -


I am getting a 404 error with the code given below, I am running Visual C # Express 2010. The string portion of the string is:

q% 3dAction% 2bMotivation% 2c% 2bInc.% 2bSouth% 2bSan% 2bFrancisco% 2b% 26alt% 3djson% 26start% 3d0% 26num% 3d10 "

  string search string = "https://www.googleapis.com/customsearch/v1%3fkey%3d {APIkey}% 26cx% 3d {cxkey} % 26q% 3dAction% 2bMotivation% 2c% 2bInc.% 2bSouth% 2bSan% 2bFrancisco% 2b% 26alt% 3djson% 26start% 3d0% 26num% 3d10 "; WebRequest myRequest = WebRequest.Create (search string); http webpressation myResponse = ( HttpWebResponse) myRequest.GetResponse ();    

You're running too much again You just want to avoid the query value A - Key / Value is not a pair separator, so the URL should be something like this:

  string url = string.Format ("https: //www.googleapis.com/customsearch/v1?key= {0} & amp; cx = {1} & amp; q = {2} ", HttpUtility.UrlEncode (APK), HTTPProduct.URLNcode (CXK), HTTPPtylty Urlcode (query));   

(Where query is original query, e.g. "Action Inspiration Inc." (I have not checked that you actually Representing escape sequences using.)

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -