Error 414 -The requested URL is too large to process - api

I am using Google Chart API in my Application and generating graph using URL "http://chart.apis.google.com"
I am getting error "The requested URL is too large to process", when I provide large set of parameters to this URL.
What I can do in this situation?

The Google Charts API FAQ offers this advice:
Is there a limit on the URL length for the Google Chart API? What is the maximum URL length?
The maximum length of a URL is not determined by the Google Chart API, but rather by web browser and web server considerations. The longest URL that Google accepts in a chart GET request is 2048 characters in length, after URL-encoding (e.g., | becomes %7C). For POST, this limit is 16K.
If URL length is a problem, here are a few suggestions for shortening your URL:
If you are using a text encoding data format, remove leading zeros from numbers, remove trailing zeros after decimal points, and round or truncate the numbers after decimal points.
If that does not shorten the URL enough, use simple (1 character) or extended (2 character) encoding.
Sample data less frequently; i.e., reduce granularity.
Remove accoutrements and decorations, such as colors, labels, and styles, from your chart.
also found this but there doesn't seem to be an answer/solution.
http://groups.google.com/group/google-chart-api/browse_thread/thread/b47c1588b39d98ce

In case it is a browser error - browsers have their maximum URL length limitations (IE 6/7 has 2,083 limit):
What is the maximum length of a URL in different browsers?

I'm getting HTTP 414 but my URL length is not an issue (it is 1881 characters), and I have tried both GET and POST. My guess is that Google will also return this error when the chart you are requesting is too "expensive" to generate.

A method that worked well for me was to divide all values by 10 or 20 and converting the results to int (no commas), but I kept the numbers on the axis. This way, it's a little less accurate but reduces the amount of characters used in the URL.
Code example:
$newSalesrank = $rank/20;
$rankdata .= intval($newSalesrank);
This solved my problem, I got no more "url too long" errors and it still looks good on my charts - because it still looked the same, the numbers just were simply scaled down.

Related

What is the best way to send String input to Google Text-to-Speech?

I have a few paragraphs that needs to be put through the Google TTS API for conversion. Some of these sentences have Dynamic words in them (eg: username). By simply passing the entire text to the API, it's taking around 8-9 secs for the Google API to respond (since some of these sentences are significantly larger in size)
What is the best strategy for converting these sentences?
I was hoping I could first convert the Static part of the sentences and store it somewhere and then convert the Dynamic part, and somehow insert the byte response of the Dynamic word. But I am not sure if this can be done at all.
For eg:
Hi, User how are you?
I was hoping to store the byte responses for "Hi," and then "how are you?" and then insert the byte response for "User" in the appropriate position

Is there a maximum number of transformations, or maximum URL length, when using Cloudinary's URL API?

I try to build my opengraph images with Cloudinary, with a few transformations to add text.
This is what I tried to do:
https://res.cloudinary.com/nho/image/fetch/e_blur:2000,c_crop,ar_1200:630,b_white/e_grayscale/w_1200/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vMjAxNy8xMC9jaHJvbWUtZW1vamktMTI4cHgtbWF4LnBuZw==,h_1.0,w_1.0,fl_relative,c_limit/b_rgb:3d2e68,o_40/w_1120,c_fit,l_text:georgia_80:Chrome%20fails%20showing%20big%20emojis,g_north_west,x_42,y_43,co_black,o_50/w_1120,c_fit,l_text:georgia_80:Chrome%20fails%20showing%20big%20emojis,g_north_west,x_41,y_42,co_black,o_75/w_1120,c_fit,l_text:georgia_80:Chrome%20fails%20showing%20big%20emojis,g_north_west,x_40,y_40,co_white/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vYXNzZXRzL3Bob3RvLWRlLW5pY29sYXMtaG9pemV5LmpwZw==,g_south_west,x_40,y_40,c_fill,w_60,r_max/l_text:georgia_50:nicolas-hoizey.com,g_south_west,x_112,y_40,co_black/l_text:georgia_50:nicolas-hoizey.com,g_south_west,x_111,y_41,co_white/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vYXNzZXRzL2xvZ29zL3R3aXR0ZXIucG5n,g_south_east,x_220,y_40,c_fill,w_50,r_max/l_text:georgia_50:nhoizey,g_south_east,x_40,y_40,co_black/l_text:georgia_50:nhoizey,g_south_east,x_41,y_41,co_white/https://nicolas-hoizey.com/2017/10/chrome-emoji-128px-max.png
I know the syntax is good, but I get a 400 Bad Request error.
If I remove the last transformation (/l_text:georgia_50:nhoizey,g_south_east,x_41,y_41,co_white) that adds text, it works:
https://res.cloudinary.com/nho/image/fetch/e_blur:2000,c_crop,ar_1200:630,b_white/e_grayscale/w_1200/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vMjAxNy8xMC9jaHJvbWUtZW1vamktMTI4cHgtbWF4LnBuZw==,h_1.0,w_1.0,fl_relative,c_limit/b_rgb:3d2e68,o_40/w_1120,c_fit,l_text:georgia_80:Chrome%20fails%20showing%20big%20emojis,g_north_west,x_42,y_43,co_black,o_50/w_1120,c_fit,l_text:georgia_80:Chrome%20fails%20showing%20big%20emojis,g_north_west,x_41,y_42,co_black,o_75/w_1120,c_fit,l_text:georgia_80:Chrome%20fails%20showing%20big%20emojis,g_north_west,x_40,y_40,co_white/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vYXNzZXRzL3Bob3RvLWRlLW5pY29sYXMtaG9pemV5LmpwZw==,g_south_west,x_40,y_40,c_fill,w_60,r_max/l_text:georgia_50:nicolas-hoizey.com,g_south_west,x_112,y_40,co_black/l_text:georgia_50:nicolas-hoizey.com,g_south_west,x_111,y_41,co_white/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vYXNzZXRzL2xvZ29zL3R3aXR0ZXIucG5n,g_south_east,x_220,y_40,c_fill,w_50,r_max/l_text:georgia_50:nhoizey,g_south_east,x_40,y_40,co_black/https://nicolas-hoizey.com/2017/10/chrome-emoji-128px-max.png
Does it mean I stacked too much transformations in one single URL?
UPDATE:
I later tried to reduce the length of the first text (added 3 times to create a shadow), from Chrome%20fails%20showing%20big%20emojis to Chrome%20fails, and it worked too:
https://res.cloudinary.com/nho/image/fetch/e_blur:2000,c_crop,ar_1200:630,b_white/e_grayscale/w_1200/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vMjAxNy8xMC9jaHJvbWUtZW1vamktMTI4cHgtbWF4LnBuZw==,h_1.0,w_1.0,fl_relative,c_limit/b_rgb:3d2e68,o_40/w_1120,c_fit,l_text:georgia_80:Chrome%20fails,g_north_west,x_42,y_43,co_black,o_50/w_1120,c_fit,l_text:georgia_80:Chrome%20fails,g_north_west,x_41,y_42,co_black,o_75/w_1120,c_fit,l_text:georgia_80:Chrome%20fails,g_north_west,x_40,y_40,co_white/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vYXNzZXRzL3Bob3RvLWRlLW5pY29sYXMtaG9pemV5LmpwZw==,g_south_west,x_40,y_40,c_fill,w_60,r_max/l_text:georgia_50:nicolas-hoizey.com,g_south_west,x_112,y_40,co_black/l_text:georgia_50:nicolas-hoizey.com,g_south_west,x_111,y_41,co_white/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vYXNzZXRzL2xvZ29zL3R3aXR0ZXIucG5n,g_south_east,x_220,y_40,c_fill,w_50,r_max/l_text:georgia_50:nhoizey,g_south_east,x_40,y_40,co_black/l_text:georgia_50:nhoizey,g_south_east,x_41,y_41,co_white/https://nicolas-hoizey.com/2017/10/chrome-emoji-128px-max.png
So I suspect the URL length might be the issue.
The issue is not the number of transformations per URL. The issue is that the transformation itself is too long. Please consider using named transformations to shorten it up.

Google Places API and Radar Search Requests in iOS

I would like to find all places (max 200) near current location, depend on types (supported types) and the distance radius (max 50 000 meters). I'm working with Google Places API in Objective-C language.
A Radar Search request is an HTTP URL of the following form:
https://maps.googleapis.com/maps/api/place/radarsearch/output?parameters
Example URL:
https://maps.googleapis.com/maps/api/place/radarsearch/json?location=48.859294,2.347589&radius=5000&types=food|cafe&keyword=vegetarian&key=API_KEY
Now I need to put name these finding places to NSString array. I must make loop which return NO when names of places in array are completly. Could you help me or give me links how to working with JSON and fetch data from JSON format?

Length of goo.gl URL's

I'm using the goo.gl link shortener API in my app to send urls to twitter along with a link. I've been allowing users to submit 119 characters, appending a space, and then the URL because I was under the impression that they were always 19 characters. This should leave me with one to spare.
Unfortunately I've been getting some "tweet is too long" errors and I can't seem to find any documentation about the possible range of goo.gl url lengths. Does anyone know what the max is or know where some reliable documentation on it is?
Twitter now automatically shortens all links by itself, using t.co. Don't do it by yourself.
Read: https://dev.twitter.com/docs/tco-link-wrapper/faq#How_do_I_calculate_if_a_Tweet_with_a_link_is_going_to_be_over_140_characters_or_not
If you are not using the opt-in features, only links shorter in length
than a t.co URL will be wrapped by t.co. All links t.co-length or
longer should be considered as t.co's maximum length. For example, if
help/configuration reports 20 characters as the maximum length, and a
user posts a link that is 125 characters long, it should be considered
as 20 characters long instead. If they post a link that is 18
characters long, it's still only 18 characters long.
At the moment short_url_length is equal 22 (https://api.twitter.com/1/help/configuration.json)

Using Google Weather API with Lat and Lon - how to format?

I want to use the Google Weather API - by passing lat and long values. I am storing these values, however it seems Google needs these values in different format.
i.e. For the town of McTavish I have values of 45.5 and -73.583
This works here: http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=45.5,-73.583
But when I use these data for Google API, it does not work: See: www.google.com/ig/api?weather=,,,45.5,-73.583
Any help appreciated. I would prefer to use the Google Data.
UPDATED ANSWER:
I have just noticed some OTHER irregularities with Google's Weather API. In ANY case, you need to have 8 numerical digits, in addition to the negative sign, if it applies. See the following code block (Java-based) for proper formatting. (Not the perfect algorithm, but just a quick example so that you can see the results)
lat = lat.replace(".", "");
while(lat.length() < 9)
lat = lat.concat("0");
if(lat.contains("-"))
lat = lat.substring(0, 9);
else
lat = lat.substring(0, 8);
ORIGINAL RESPONSE:
Paul, the trick about Google's Weather API is that you don't use the coordinates as received by traditional latitude/longitude. Instead, you parse out the decimal points. Additionally, a "fun quirk" of Google's Weather API seems to be a requirement that the data come in as a 7- to 8-digit string. So, for instance, 45.5 should really be 45.50000, and -73.583 should really be -73.58300. This length of 7-8 digits does NOT seem to include the negative sign (-) in front of any negative coordinates.
So, your 45.5(0000) becomes 4550000, and your -73.583(00) becomes -7358300. So the final URL would be:
http://www.google.com/ig/api?weather=,,,4550000,-7358300
Note that again, 7-8 digits means 4550000 or 45500000 would be acceptable, as would -7358300 or -73583000.
I only found out about the 7-8 digit length when I saw your question--I tried entering the data into my weather parsing program, and found that 455,-73583 does not yield proper data.
Note that this is by my unofficial experimentation, and not by official documentation, so there may be other quirks to be discovered.
It's much simpler - latitude & longitude should be multiplied by one million
In my opinion longitude an latitude must be coded in _e6 format (six last digits must be the decimal part of the lon/lat string passed to the API). Then you must adjust first decimals to a length of six, you add 0s if you have fewer than six decimals, and you clip it to 6, if you have more. For the int part if you have just one character you must add a zero first, for two or three digits, you don't need to do anything.
Examples:
1.1234 must be coded as: -01123400
112.2345 must be coded as: 112234500
34.123456 must be coded as
Here you have a explanation with examples and a the php source code (the blog is written in Spanish).
As Miguel said it is the last 6 digits that should be the decimal places. So the correct code is as simple as....
string.Format("http://www.google.com/ig/api?weather=,,,{0:0},{1:0}",
(latitude * 1000000),
(longitude * 1000000));