I migrated my project from Dropbox API version 1 to 2 and it returns error code 400 (Bad request) when I try to load xml file from Dropbox.
I have read the documentation but somehow I still don't understand how to correctly structure version 2 URLs.
What would be the correct V2 url to load an XML file?
I'm loading XML like this:
XmlDocument xmlDoc = new XmlDocument();
string uri = new Uri(string.Format(...)).AbsoluteUri;
xmlDoc.Load(uri);
Version 1 (deprecated)
string.Format("https://content.dropboxapi.com/1/files/auto{0}?access_token={1}", svcUri, ACCESS_TOKEN)
Version 2 (current)
// What is wrong here??
string.Format("https://content.dropboxapi.com/2/files/download{0}?access_token={1}", svcUri, ACCESS_TOKEN)
In your version 2 code, you're attempting to put the file path directly on the URL path, and are passing the access token in an access_token path. These worked on API v1, but API v2 is a different interface so those won't work there.
In API v2, you're correct that the replacement is /2/files/download. That's a "content-download endpoint", so the standard way of using that is via a POST with 'Authorization' and 'Dropbox-API-Arg' headers.
To just use a GET with it instead though, as it appears you want to do, i.e., so you can just use a URL by itself, you can use the URL parameters documented here under "Request and response formats".
So, to access a file at "/folder/filename.xml" the API call parameters for /2/files/download would be:
{"path": "/folder/filename.xml"}
URL encoding those for use with the arg URL parameter, along with the access token information in the authorization URL parameter, the result would be:
https://content.dropboxapi.com/2/files/download?authorization=Bearer%20ACCESS_TOKEN&arg=%7B%22path%22%3A%20%22%2Ffolder%2Ffilename.xml%22%7D
Be sure to replace ACCESS_TOKEN with the actual access token.
Related
What is the best way to deal with special characters in URL's with ServiceStack and a Javascript Axios client, or any other client.
Example:
URL Path: /MasterItems/{Code} - Code can have any character in it, (/ \ & etc.)
The above URL could be generated by the API (backend), so it will come back from a previous request as part of the response _links.
Example: of the response _links
/MasterItems/A1200G/FA (the code is A1200G/FA)
My frontend code, (VueJS, Javascript, Axios) will simply get the _links resource and call the GET.
How should I treat this, turn my GET into POST and pass a parameter?
Encode the URL?
Note:
I noticed when using the built-in swagger feature of ServiceStack the resulting call works.
The URL will be: /MasterItems/%7BCode%7D?Code=A1200G%2FA
This C# code, with a proper access token (for scope drive.readonly) in the Authorization header, will work fine and return the file metadata in json format
_httpClient.GetAsync($"https://content.googleapis.com/drive/v3/files/{someDriveFileId}")
However this code (still with the same access token) will return a 403 :
_httpClient.GetAsync($"https://content.googleapis.com/drive/v3/files/{someDriveFileId}?alt=media")
And the following response html (exactly as returned) :
<html><title>Error 403 (Forbidden)!!1</title><a
href=//www.google.com/><span id=logo
aria-label=Google></span></a><p><b>403 Forbidden</b><p>Your client
does not have permission.\n
I've been using this code in production for years and it worked fine, so i suppose it's related to the recent changes at Google regarding the OAuth screens ?
I'm not sure what i should change here, or what i'm doing (now) wrong. Also the message seems a little sketchy for something made at Google, makes me think there is maybe an issue on their side ?
UPDATE:
Thanks to #Iamblichus for fixing the layout of my original answer. I'm newer to stackoverflow posting.
Even though the change in the original answer appears to be at the root of the problem, I found it difficult to use the troubleshooting steps to come to a working solution. I also was already passing the Authorization Bearer token solution, and that was not fixing my problem. After some trial and error the change I had to make was:
Broken GET URL:
https://content.googleapis.com/drive/v2/files/MY_FILE_ID?key=MY_KEY&alt=media&source=downloadUrl
Working GET URL:
https://www.googleapis.com/drive/v2/files/MY_FILE_ID?alt=media&source=downloadUrl
NOTE:
I am using v2 of the API, so you would need to update to url to v3 if using that.
In the file object I get from the google filepicker v2 API, I don't get back a single URL that supports the change made in authentication. I had to concat the file.selfLink string to make the new URL work
var url = file.selfLink + "?alt=media&source=downloadUrl";
ORIGINAL ANSWER:
Is it possible that https://cloud.google.com/blog/products/application-development/upcoming-changes-to-the-google-drive-api-and-google-picker-api is your problem?:
download calls to files.get, revisions.get and files.export endpoints which authenticate using the access token in the query parameter will no longer be supported.
Only requests that download media content (alt=media) are affected by this change.
The access token should be provided in the HTTP header, like Authorization: Bearer oauth2-token or, if that's not possible, follow the workarounds provided in the referenced documentation:
For file downloads, redirect to the webContentLink which will instruct the browser to download the content. If the application wants to display the file to the user, they can simply redirect to the alternateLink in v2 or webViewLink in v3.
For file exports, redirect to the export link in exportLinks with the desired mime type which will instruct the browser to download the content.
Reference:
Changes in authorization to Google Drive API
Authorization via HTTP header
v2 files get documentation
v3 files get documentation
Implementing a code of Embedded Signing in MVC C# Project. When I post for the sign document, It's redirecting to DocuSign page and it will redirect to return URL. using below code
private const string returnUrl = "http://localhost:5050/DSReturn";
...
return Redirect(viewUrl.Url);
Here I want to get that signed document in response instead of email. How this is possible? or is there any other way to get signed document after finish signature process?
You would make the API call to the "document" resource (.../documents/{documentId or constant}).
The post-signing redirect URL is for the purposes of continuing your web workflow. The "event" parameter allows your web application to generate the correct page or results. For example, in the "Loan Co" example at the Dev Center generates a post-signing page that has links for the document, which in turn result in the API call to retrieve the document. In a real-world integration, the redirect URL is not a reliable indicator that the envelope is "completed". For example, the signer could close the browser before the redirect was executed, or the envelope may have subsequent signers. The Connect service provides a much more reliable trigger for downloading the documents.
Expanding on what #WTP mentioned, you have a couple of approaches. First is via a raw API call using the /v2/accounts/{accountId}/envelopes/{envelopeId}/documents/{documentId} endpoint and retrieving the file from the response. More information can be found here.
Another option you may or may not be aware of is using the DocuSign Client NuGet package. Your code would then look something like this pseudocode:
Stream documentStream = EnvelopesApi.GetDocument(accountId, envelopeId, documentId);
If you are not using the NuGet package yet, keep in mind there is setup work that you will have to do to set-up the EnvelopesApi. That information can be found here.
I am trying to use FileMaker's XML WebPublishing feature. When I try to request a database from filemaker via Mozilla I get a user/pass request..when I enter that info the XML file loads. When I try this on IE, I get a blank result.
I then tried to use c#'s webrequest function to load the URI and I am getting a blank result when using the network credentials, when i omit the credentials I get a 401 unauthorized error (expected); I can't seem to figure out why I am getting a blank result.
I'm not sure if this will work, but have you tried inserting the credentials into the URL?
http://user#password:server.company.com/fmi/xml/fmresultset.xml?-db=...
There was a same question, how to get data from FileMaker database. I know 3 solutions:
1. FileMaker php Api. Use to create web service between database and your application
2. FileMaker XML Api. It's easier than first solution, and no need know php.
3. Now open sourced RESTfm project that uses XML and php api's and create a simple web service to fetch data in JSON format.
Hope it will help you.
I am working with twilio.com api in C#.net. C# code calls the phone number I have given:
string accountSid = "AC5xxxxxxxxxfdb0cf485d52ce";
string authToken = "57fxxxxxxxxx1xxx71a";
var client = new TwilioRestClient(accountSid, authToken);
var request = new CallListRequest();
var callList = client.ListCalls(request);
var options = new CallOptions();
options.Url = "http://demo.twilio.com/docs/voice.xml";//
options.To = "+919876123456";
options.From = "+15163425887";
var call = client.InitiateOutboundCall(options);
MessageBox.Show(call.Sid);
I call my phone through above given code, picking up the call connects me to the xml file (a twiML file) mentioned in options.Url and I listen the message and .mp3 file mentioned in voice.xml. Now I want to replace this xml file with my custom xml file placed in a server. For testing purpose I created the exact copy of voice.xml and placed it into my server. So I change the url property to:
options.Url="http://productionserver.com/voice.xml";
After making this change when I pick the phone, it says "Application error has occurred" and call ends.
Has anyone worked with twilio and experienced such problem ? Is there any step that I am missing other than just creating an xml file ?
Twilio evangelist here.
First I'd suggest checking to see if anything got logged in your App Monitor. I suspect you will see Twilio has logged a 500 error there.
If you are trying to serve the raw XML file from IIS, then your probably running into the issue that IIS won't serve an XML file from a POST request, which is the default HTTP Method Twilio uses to request the Url.
There are a couple of work-arounds for this:
You can set the Method property on the CallOptions to GET which tells Twilio to make its request using the HTTP GET method OR
Since this is static XML you are serving, you cold use http://twimlbin.com to host the TwiML
Hope that helps.