Dropbox getTemporaryLinks API errors description - dropbox

I received an email from Dropbox states from middle of october get temporary links api will returns an email_not_verified error in case user not verified her email address, so far so good.
I'm able to get the response body from the doc https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_link
Since I'm using dropbox java sdk and I'm used to code test first, I was trying to simulate the scenario, but having the json inside the http response, I've an error parsing the json inside dbx library. So I tried changing the status code and, having 409 I got com.dropbox.core.v2.files.GetTemporaryLinkErrorException: Exception in 2/files/get_temporary_link: "other"
but it is not enough, since I need to manage the scenario.. Can someone help me understanding what I can check in the code but first of all, what is the response I've to simulate in my unit test?
Thanks in advance

The other error case indicates that it's an error that the SDK you're using does not recognize. The GetTemporaryLinkError.email_not_verified error is relatively new, so you'll need to make sure you're using a recent enough version of the SDK to be able to identify it. For the GetTemporaryLinkError.email_not_verified error, that is v3.1.0 or later of the Dropbox Java SDK. (It's best to just get the latest anyway, which is currently v3.1.1.)
If you're are using an updated version of the SDK, it's also possible you're just not setting valid JSON for the GetTemporaryLinkError.email_not_verified error case when you're trying to simulate this. You can find the valid JSON for this error case in the /2/files/get_temporary_link documentation. Make sure you copy that as shown there if you're trying to simulate this.
Lastly, to actually catch that error with the Dropbox Java SDK, you'll want to catch GetTemporaryLinkErrorException thrown by getTemporaryLink. To check for the specific case, check the GetTemporaryLinkErrorException.errorValue. The GetTemporaryLinkError.isEmailNotVerified will return true for the unverified email case.

Related

Synology FileStation API

Hi I am trying to synology api to download a file, it seems that the API documentation is outdated,
I successfuly login and logut using the API,
but when I tried to use this api call
http://myds.com:5000/webapi/entry.cgi?api=SYNO.FileStation.Info&version=1&method=getinfo
the response sends error 103, "Method do not exists".
According with the documentation, first, you have to retrive the cgi path,in my case is "entry.cgi".
then you know that part of the api direction
/webapi/?api=&version=&method=[&][&_sid=]
According with the error 103 the (in this case is getinfo) doesn't exists, but the documentation tells other thing.. and it's driving me crazy
https://global.download.synology.com/download/Document/Software/DeveloperGuide/Package/FileStation/All/enu/Synology_File_Station_API_Guide.pdf
Someone has used Synology api recently? I need to figure out how to use the SYNO.FileStation.Download api call.
I'm afraid you will need to look into the code of the filestation php files.
Here are some impressions of how this was done for the PhotoStation:
https://gist.github.com/anthonydahanne/4583444
https://blog.jbowen.dev/synology/photostation/getting-started/get-api-info/
Similar to PhotoStation I would first search for the info-method to check what the API is supposed to offer.
I just happened to come across your thread, have you tried viewing the APIs available on your Diskstation? You can do that by calling
http://<YourDiskstationURL:Port>/webapi/query.cgi?api=SYNO.API.Info&version=1&method=query&quer%20y=all
I have a function that looks like the successor to the download function:
{"maxVersion":2,"minVersion":1,"path":"entry.cgi","requestFormat":"JSON"}
,"SYNO.FileStation.Download":
In the API-documentation Synology suggests to check whether a specific API is available or if it has changed.

API response, with multiple error information

I was building my API when this question came out:
I am making an API to set or get stuff, for the example i try to set but i have two field with error, what's the best way to answer the errors ?
Answer only one error ?
Answer all the errors ?
In my opinion, answer all the errors is the best solution but not for my boss .
What's the best for this kind of work ?
Definitely all validation errors should be pass back to client.
Moreover, you should specify code of errors, while error message can vary for different situation. Standard error codes can help you to create
tests for your api.
Also you should add versioning for your api from the beginning, because when you open your api for clients it should be stable. And incompatible changes can be done only in next version
of your api

Accessing Metacritic API and/or Scraping

Does anybody know where documentation for the Metacritic api is/if it still works. There used to be a Metacritic API at https://market.mashape.com/byroredux/metacritic-v2#get-user-details which disappeared today.
Otherwise I'm trying to scrape the site myself but keeping getting a blocked by a 429 Slow down. I got data like 3 times this hour and haven't been able to get anymore in the last 20 minutes which is making testing difficult and application possibly useless. Please let me know if there's anything else I can be doing to scape I don't know about.
I was using that API as well for an app I wrote a while ago. Looks like the creator removed it from Mashape. I just sent him an email to ask whether it'll be back up. I did find this scraper online. It only has a few endpoints but following the examples given you could easily add more. Let me know if you make any progress!
Edit: Looks like CBS requested it to be taken down. The ToS prohibits scraping:
[…] you agree not to do the following, or assist others to do the following:
Engage in unauthorized spidering, “scraping,” data mining or harvesting of Content, or use any other unauthorized automated means to gather data from or about the Services;
Though I was hoping for a Javascript way of doing this, the creator of the API also told me some info.
He says I was getting blocked for not having a User agent in the header and should use a 429 handling procedure i.e. re-request with longer pauses in between.
A PHP plugin available as well: http://datalinx.io/shop/metacritic-api/
I had to add a user agent like JCDJulian said and now it allows me to scrape. So for Ruby:
agent = Mechanize.new
agent.user_agent_alias = "Mac Firefox"
Then it stopped giving me the 403 Forbidden error.

Jira V6.0+ creating a project over REST API

I've got a problem: I'm working on an external webinterface for my company and we use Atlassians JIRA as a project issue and tracking method. I am trying to connect our webinterface over the REST API. After a short research I found out, that Atlassian never implemented the possibility to create a new JIRA Project over their REST API. Well, that isn't that true, they've implemented it in the actual version (7.0) because they migrated their other two APIs to one REST API. Now comes my problem: We are currently unable to upgrade from version 6.4.4 to version 7.0.0. After a second search I found a workaround for this problem. You can find it here:
The real problem is that this workaround isn't working or I'm doing it wrong.
I've already tried it with a GET request and the given arguments as parameters and over the normal POST method with a JSON body in it.
What's my problem?
Here some more informations: When I try it over GET, I always receive the normal response for the URL (it returns a list with all available templates). When I try it over POST with a JSON body (this is by the way the normal method for the normal functions of the REST API) I get back a HTTP-Error 415 Unsupported media type.
it would be nice if someone could test this workaround with a 6.0+ version of JIRA
So after some months I got it by myself. You have to make a POST request with the following header fields:
Content-Type=application/x-www-form-urlencoded; charset=UTF-8
Authorization=Basic {set your credentials as a Base64-String: "user:password"}
X-Atlassian-Token=nocheck
Once done you can set your POST-Parameters to the following:
name=Name of the Project
key=Key of the Project
lead=Leader of the Project
keyEdited=true (don't change it!)
projectTemplateWebItemKey=com.atlassian.jira-legacy-project-templates:jira-blank-item (don't change it!)
projectTemplateModuleKey=com.atlassian.jira-legacy-project-templates:jira-blank-item (don't change it!)
Hope that this helps someone, Jira is just weird in some cases :/

Google+ .Net API - Getting Authenticated and retrieving profile

I'm trying to get a users profile information for google+ via the .NET API but am having trouble.
Does anyone know if they have changed how the special ID "me" works?
In the documentation it says this can be used as a special ID to get the currently authenticated users information however this throws a 404 from both the API in my code and on Google's own test page https://developers.google.com/+/api/latest/people/get. I was logged in when trying this.
Does anyone know how to get the user ID as I would happily use that instead of me but it isn't returned after the user authenticates as far as I can see (just an authcode)?
I also tried using user IDs returned when using the standard .net Oauth stuff but it isn't the correct ID, I assume it is for something else.
As for my method of getting to this stage, I first downloaded the example files here: http://code.google.com/p/google-api-dotnet-client/wiki/GettingStarted
They don't have a plus example so I took the Tasks.ASP.NET.SimpleOAuth2 example and swapped out tasks (which worked fine) for the plus equivalent.
I also tried rolling this into my own project.
Neither worked. I get the user forwarded to Google where they give me access fine and then when I return they are authenticated successfully as far as I can see, however when I call service.People.Get("me") it returns a 404.
If anyone could help with the above questions (using me, or gettign the user ID) I would appreciate it.
To the moderator who closed the initial version of this question, I have tried to make this as direct a question as possible so please don't close it. This is a legitimate question I would really like help getting to he bottom of.
This is now out of date given recent platform updates. Although the plus.me scope still exists and this code will work, you should be using the plus.login scope for retrieving profile data in C#. For a great way to get started with retrieving and rendering profile information, please start from the Google+ C# quick start available here:
https://developers.google.com/+/quickstart/csharp
First off, the 'me' id still works and is unchanged. The way that it works is:
You authenticate the user using a standard OAUTH2 flow
You use the library to perform a People.get with the special value 'me'
The 404 error code is a little troubling, this means that the client isn't finding the endpoint. To debug this, you might want to use a packet sniffer like fiddler to see what the actual URL it's querying is.
Anyways, how about some C# code. The following example shows how to use the plus service to get the currently authenticated user (assuming you have authenticated someone). What's different from your snippet is that you need to form a get request for the API call, then run fetch on the get request. I've included the following example, for getting 'me', and the following code works:
var auth = CreateAuthenticator();
plusService = new PlusService(auth);
if (plusService != null)
{
PeopleResource.GetRequest prgr = plusService.People.Get("me");
Person me = prgr.Fetch();
}
All of the configuration of the server and getting a client working is pretty hard and pasting all of the code here would be less helpful than just giving you a sample.
And so... I have written a sample application that demonstrates how to do this and also includes a wrapper that makes it easier to develop using the Google+ API in C#. Grab it here:
Google+ C# Server-Side demo and library
Seems you need to use:
Person test = service.People.Get("me").Fetch();
and not
req = service.People.Get("me");
Person test = req.Fetch();
Even though they seem to be identical the first works and the second doesn't.
Still not sure why google's own page doesn't work though. Now to find out how to add things to the scope like birthday.