Google short url API error - short-url

We are using the Google API to shorten our URL. This API works for smaller URL but when we tried to shorten bigger URL then it throws 400 error. Is there any maximum limit to shorten the URL or there is any solution to resolve this error? Because sometime our becomes to big say suppose thousands of character at time it throws error.

Related

PageSpeed Insights API returning 401 error at seemingly random times

We are programmatically calling the PageSpeed Insights API for an internal list of websites. The majority of the time it works fine, but at seemingly random times we are getting the error "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential..." When the error occurs we log the url that was used for the request as well as the error. As a result I can copy the exact url that generated the error and paste it into a browser (or Postman), https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://www.xyzsite.com/&strategy=mobile&locale=en&key={validAPIkey} for instance, and get a valid response. The fact that the same API key is being used for all requests I know it's valid so I have no idea what might be causing this error. Has anyone else run into this? Does anyone have any idea what might be causing this error to occur on a seemingly random basis?
I also experience the same issue. As on page 5 to 10 API are called with same API key and credentials. Token is also not expired but it generate 401 randonly on different API. See attached image

Cannot successfully make here map requests using my api key

I cannot get a success response using the example code shown in the here documentation: https://developer.here.com/documentation/routing/dev_guide/topics/request-constructing.html
I created a Freemium account and generated two each of JS and REST api keys. Regardless of which key I try, I keep getting errors that seem to change with each attempt:
Sometimes a 404
Sometimes a 502
Sometimes a 504
Sometimes a 403 with a message I might understand if it happened every time:
{
Message: "User: anonymous is not authorized to perform: es:ESHttpGet"
}
Sometimes a 200 with a page not found error message from something called
Platform's Radar
Sometimes a 302 that redirects to a login for Kibana using a Live Nation account
For reference, a specific request from the documentation that I have been trying:
https://route.ls.hereapi.com/routing/7.2/calculateroute.json?apikey={API_KEY}&waypoint0=geo!52.5,13.4&waypoint1=geo!52.5,13.45&mode=fastest;car;traffic:disabled
I am really not sure what is going on here.
On replicating the API call, it is resulting 200 every time. For reference find screenshot, please use correct APIkey

Data is not returned for every URL input

I am not getting the labels and other properties on all the URL's when using the Google Vision API. It randomly gives this error on some URL.
{'responses': [{'error': {'code': 7, 'message': "We're not allowed to access the URL on your behalf. Please download the content and pass it in."}}]}
As in, on some runs I don't see this error on the URL and get data, and on the other runs I see the error.
Are you trying to access an image on someone else's server? It's possible that they're throttling your access, so that the Vision API can't access the image each time. You may have to slow down your requests.

IIS gives 400 Bad Request for some links

I'm using ASP.NET Identity for generating activation urls in format
https://example.com/activate/token
Where token is generated by Asp Identity and looks like this
Cl%2bsBAAAA2qxQHU9GHUuBNXILrSEDWgAAAAACAAAAAAAQZgAAAAEAACAAAADds1gNf52iBX54Z6V%2bY5ZJEZmCmhgPetK2mEuu5pEiLwAAAAAOgAAAAAIAACAAAADjqFZ3Qrk6o22AHQDtoo%2bUNO4NZZ9RubxnuFBPTwyX/3AAAAATHRJIHkbDX2PmNxDYV0e2P5uAohDpMlpaP1C/KjV1mz5z06X7YaehipzlgLa4IxcAT8AQK%2bW4Qxq4Y3No0kaVNQRpSIzdB6cv%2bjn47IY5hburRgSPbZ6L7xvmWoreBZCCBn4SHMxbcdfAKEnkDELpQAAAAIwoV4hLdqQyV5g6WAQM/kiO3/FKyauZKsWBI/tA/M7uq7CDiQRdZxqdO0SUO9xW851luaKDP6bi/daxEhAemzk%3d
Problem is sometimes ~1 in 10 times I get generic 400 error
Bad Request - Invalid URL
HTTP Error 400. The request URL is invalid.
Example bad link
http://example.org/activate/AQAAANCMnd8BFdERjHoAwE/Cl%2bsBAAAA2qxQHU9GHUuBNXILrSEDWgAAAAACAAAAAAAQZgAAAAEAACAAAACrbeGsadAFQETqBTsIuxf%2bJZqK0JOQvGC6M250gHsTEQAAAAAOgAAAAAIAACAAAACo6YtEGtjrvRO74X2G2VAQ1pAlBWksjnLo0zGxwrVrSXAAAAA%2bFfiwK3sL%2bbzK9wbM0r7Hoy4tueNmh4CNLD%2b2HeP7IldrAq40XbeLW0zlZo3CC2qWBfaGb5Z4HjziVYVT2Fvpg6dtm9UAmI4h5BPjzIBcJo8ZpiE4Z%2bQedRpAijhMHfsV2IDNptzCREWe3Wefi9aoQAAAAPzg9TNEhsqf76Qir%2bIyMxuuPsQkVykZVYFJ9/aI3EAAWK2de2VTUsXQBgdS4OGSI4AaAUEN%2b0Akdohw3Jd8zFo%3d
I think the problem is somewhere in IIS request is not hitting my application anywhere and, that's very strange, same error is showing on other websites like microsoft.com.
Eg.this makes 400 error
https://microsoft.com/en-us/AQAAANCMnd8BFdERjHoAwE/Cl%2bsBAAAA2qxQHU9GHUuBNXILrSEDWgAAAAACAAAAAAAQZgAAAAEAACAAAACrbeGsadAFQETqBTsIuxf%2bJZqK0JOQvGC6M250gHsTEQAAAAAOgAAAAAIAACAAAACo6YtEGtjrvRO74X2G2VAQ1pAlBWksjnLo0zGxwrVrSXAAAAA%2bFfiwK3sL%2bbzK9wbM0r7Hoy4tueNmh4CNLD%2b2HeP7IldrAq40XbeLW0zlZo3CC2qWBfaGb5Z4HjziVYVT2Fvpg6dtm9UAmI4h5Bhsqf76Qir%2bIyMxuuPsQkVykZVYFJ9/aI3EAAWK2de2VTUsXQBgdS4OGSI4AaAUEN%2b0Akdohw3Jd8zFo%3d
but this 404 error
https://www.microsoft.com/en-us/AQAAANCMnd8BFdERjHoAwE/Cl%2bsBAAAA2qxQHU9GHUuBNXILrSEDWgAAAAACAAAAAAAQZgAAAAEAACAAAAAbr0DBVHVcY2tO3Rvvk15d5%2bIuV3usPJmD2FTF15vpbwAAAAAOgAAAAAIAACAAAAAXddKnTogsgCGRRhIzbXbk14fsjcLJ5L0q5C/dRfsYlHAAAAAlAw9iARuxhShyGfzE6ZF193fX7zvxLnOfjgh74G5oLc5RPIVdQ7O8sJdj5H0BnysPxrCMk965izZRqjBKGZFNl6smYdmaGy5aPqxI1kTez%2bhHQH1GMW3GUmF%2bRoYdRqcmJLErgcb4sgMa7UGA16X1QAAAAJTk6s6OzBuA2B8whkUdwQnrCS2xgf7QR%2blA%2bm7UqUdXuhQfiFkL/oCINhyrJt%2bWJsjxvGhOcsW15DtzyqKvlWY%3d
It looks like length sometimes have meaning but not really?
Similar question but caused by known characters - %09 in a URL causes IIS (HTTP.SYS?) to return HTTP 400 immediately
PS. Url in format http://example.com/activate?token=token work fine
I think it is caused by the max length for Url segment (UrlSegmentMaxLength).
Source: https://support.microsoft.com/it-it/help/820129/http-sys-registry-settings-for-windows

Google Analytics Data Feed 400 Bad Request on First Request Only

I have an inherited VB6 program that runs each morning to download Google Analytics feed data for several clients. The process does the following:
Checks that my current OAuth 2.0 Access Token (saved in my database from yesterday) has not expired, and if so obtains a new one. Naturally, when the program runs for the first time each day it gets a new Access Token.
For each client, post a request for feed data.
Processes the XML data received from the Google server.
My problem is with step 2 above. The first post using the new Access Token always fails with a 400 Bad Request error. Making a second post using the exact same data always succeeds and my program can move to step 3.
Here is an example of my POST (with Client Id and Access Token in [ ] brackets):
https://www.google.com/analytics/feeds/data?
ids=ga%3A[Client Id]&
start-date=2016-01-10&
end-date=2016-01-10&
metrics=ga%3Asessions%2Cga%3Atransactions%2Cga%3AtransactionRevenue&
dimensions=ga%3Amedium%2Cga%3Asource%2Cga%3Akeyword&
filters=ga%3Asource%3D%3Dshopping&
access_token=[Access Token]
This has been occurring for several weeks.
The error description (Err.Description) from my code is "400 Bad Request". The entire response from the Google server (less HTML) is "400. That's an error. Your client has issued a malformed or illegal request. That's all we know."
Can anyone offer any suggestions as to why the first request fails, but subsequent requests don't? I have even built in a five minute delay between getting the new Access Token and making the first data request, but still get the 400 Bad Request Error.
Any help you can offer would be greatly appreciated.
Thanks.
Using Fiddler (thank you M Schenkel) I was able to finally track the source of the problem.
My VB6 program is using the IP*WORKS! SSL component from nsoftware. The form had a single HTTPS component that was being used for (1) getting a new Access Token, and then (2) for getting the feed data.
Fiddler showed that the second use of the component was using some of the parameters from the first use of it.
I added a second HTTPS component to the form so my feed data request would start off with a blank slate and it worked.
Thank you very much for your help!

Resources