<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: 'HTTP Error 400 Bad request' while attempting to call 'create_shared_link_with_settings' Dropbox api from vb .net for windows desktop app in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/HTTP-Error-400-Bad-request-while-attempting-to-call-create/m-p/162282#M5638</link>
    <description>&lt;P&gt;Ok, I fixed my code to be able to read 'the body of the response' by performing a cast from the vb exception class. What I've got is this:&lt;/P&gt;
&lt;P&gt;"Error in call to API function "sharing/create_shared_link_with_settings": This function requires its argument in the HTTP request body, but your request body is empty."&lt;/P&gt;</description>
    <pubDate>Thu, 17 Mar 2016 02:58:31 GMT</pubDate>
    <dc:creator>requiencat ..</dc:creator>
    <dc:date>2016-03-17T02:58:31Z</dc:date>
    <item>
      <title>'HTTP Error 400 Bad request' while attempting to call 'create_shared_link_with_settings' Dropbox api from vb .net for windows desktop app</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/HTTP-Error-400-Bad-request-while-attempting-to-call-create/m-p/162279#M5635</link>
      <description>&lt;P&gt;Hi. I'm developing a windows desktop app in order to get the dropbox links of the files inside my dropbox directory. I want to use the &amp;nbsp;'create_shared_link_with_settings' Dropbox api but when I execute POST method I only get vb exception: 'HTTP Error 400 Bad request'.&lt;/P&gt;
&lt;P&gt;I'm a basic Dropbox user and developing app for personal use (I don't need to enable additional users). I registered my app and got OAuth2 token.&lt;BR /&gt;&lt;BR /&gt;The data I'm sending is:&lt;BR /&gt;{"path":"/Public/MyFile.pdf","settings":{"requested_visibility":"public"}}&lt;BR /&gt;&lt;BR /&gt;In the headers:&lt;BR /&gt;"Authorization: Bearer myOAuth2TokenHere" &lt;BR /&gt;&lt;BR /&gt;And the url: "&lt;A href="https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings" rel="nofollow noreferrer" target="_blank"&gt;https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings&lt;/A&gt;"&lt;BR /&gt;&lt;BR /&gt;Here is the vb .net [FrameWork 4.0] code I'm using.&lt;/P&gt;
&lt;P&gt;Dim sFormattedFilePath As String = ""&lt;BR /&gt;Dim sUri As String = ""&lt;BR /&gt;Dim sData As String = ""&lt;BR /&gt;Dim sJSON As String = ""&lt;BR /&gt;Dim pHeader As WebHeaderCollection = Nothing&lt;BR /&gt;Dim pRequest As HttpWebRequest = Nothing&lt;BR /&gt;Dim pResponse As HttpWebResponse = Nothing&lt;/P&gt;
&lt;P&gt;Try&lt;BR /&gt;&amp;nbsp; sFormattedFilePath = "/Public/MyFile.pdf"&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; sData = "{" &amp;amp; Chr(34) &amp;amp; "path" &amp;amp; Chr(34) &amp;amp; ":" &amp;amp; Chr(34) &amp;amp; sFormattedFilePath &amp;amp; Chr(34) &amp;amp; "," &amp;amp; Chr(34) &amp;amp; "settings" &amp;amp; Chr(34) &amp;amp; ":{" &amp;amp; Chr(34) &amp;amp; "requested_visibility" &amp;amp; Chr(34) &amp;amp; ":" &amp;amp; Chr(34) &amp;amp; "public" &amp;amp; Chr(34) &amp;amp; "}}"&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; pHeader = New WebHeaderCollection()&lt;BR /&gt;&amp;nbsp; pHeader.Clear()&lt;BR /&gt;&amp;nbsp; pHeader.Add("Authorization: Bearer myOAuth2TokenHere")&lt;/P&gt;
&lt;P&gt;&amp;nbsp; sUri = "&lt;A href="https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings" rel="nofollow noreferrer" target="_blank"&gt;https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings&lt;/A&gt;"&lt;BR /&gt;&amp;nbsp; pRequest = DirectCast(HttpWebRequest.Create(sUri), HttpWebRequest)&lt;BR /&gt;&amp;nbsp; pRequest.ContentType = "application/json"&lt;BR /&gt;&amp;nbsp; pRequest.ContentLength = sData.Length&lt;BR /&gt;&amp;nbsp; pRequest.Headers = pHeader&lt;BR /&gt;&amp;nbsp; pRequest.Method = "POST"&lt;BR /&gt;&amp;nbsp; Using s As Stream = pRequest.GetRequestStream()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; s.Write(System.Text.ASCIIEncoding.Default.GetBytes(sData), 0, sData.Length)&lt;BR /&gt;&amp;nbsp; End Using&lt;BR /&gt;&amp;nbsp; pResponse = DirectCast(pRequest.GetResponse(), HttpWebResponse)&lt;BR /&gt;&amp;nbsp; Using sr As New StreamReader(pResponse.GetResponseStream())&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sJSON = sr.ReadToEnd()&lt;BR /&gt;&amp;nbsp; End Using&lt;BR /&gt;Catch ex As Exception&lt;BR /&gt;&amp;nbsp;&amp;nbsp; MsgBox(ex.Message)&lt;BR /&gt;End Try&lt;/P&gt;
&lt;P&gt;If you are wondering: &lt;BR /&gt;&lt;BR /&gt;The content of var sData is&lt;BR /&gt;{"path":"/Public/MyFile.pdf","settings":{"requested_visibility":"public"}}&lt;BR /&gt;&lt;BR /&gt;The exception occurs when executing line: &lt;BR /&gt;pResponse = DirectCast(pRequest.GetResponse(), HttpWebResponse)&lt;BR /&gt;&lt;BR /&gt;And the message of exception is:&lt;BR /&gt;HTTP Error 400 Bad request&lt;BR /&gt;&lt;BR /&gt;I used exactly the same vb.net code when calling 'get_shared_links' api and it worked fine, that's why I was sure the code was correct but when I call 'create_shared_link_with_settings' the code doesn't work.&lt;BR /&gt;&lt;BR /&gt;Any clue of what's happening?? please Help :'(&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:34:52 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/HTTP-Error-400-Bad-request-while-attempting-to-call-create/m-p/162279#M5635</guid>
      <dc:creator>requiencat ..</dc:creator>
      <dc:date>2019-05-29T09:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: 'HTTP Error 400 Bad request' while attempting to call 'create_shared_link_with_settings' Dropbox api from vb .net for windows desktop app</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/HTTP-Error-400-Bad-request-while-attempting-to-call-create/m-p/162280#M5636</link>
      <description>&lt;P&gt;What's the body of the response? It should contain more useful error information.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2016 01:40:52 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/HTTP-Error-400-Bad-request-while-attempting-to-call-create/m-p/162280#M5636</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-03-17T01:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: 'HTTP Error 400 Bad request' while attempting to call 'create_shared_link_with_settings' Dropbox api from vb .net for windows desktop app</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/HTTP-Error-400-Bad-request-while-attempting-to-call-create/m-p/162281#M5637</link>
      <description>&lt;P&gt;My code saves 'the body of the response' into the var: sJSON however, my code crashes before it gets to the line which reads that response. In this case, the one who is throwing the exception is the vb.net compiler.&lt;/P&gt;
&lt;P&gt;I don't know if it could be useful but analyzing the information included into the vb.net exception I found this:&lt;BR /&gt;&lt;BR /&gt;Headers = {Transfer-Encoding: chunked&amp;nbsp; Connection: keep-alive&amp;nbsp; X-Dropbox-Request-Id: baad501b308ddd5c1310f7af856563fe&amp;nbsp; Content-Type: text/plain; charset=utf-8&amp;nbsp; Date: Wed, 16 Mar 2016 19:02:33 GMT&amp;nbsp; Server: nginx&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;StatusCode = BadRequest {400}&lt;BR /&gt;StatusDescription = "Bad Request"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2016 02:25:40 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/HTTP-Error-400-Bad-request-while-attempting-to-call-create/m-p/162281#M5637</guid>
      <dc:creator>requiencat ..</dc:creator>
      <dc:date>2016-03-17T02:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: 'HTTP Error 400 Bad request' while attempting to call 'create_shared_link_with_settings' Dropbox api from vb .net for windows desktop app</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/HTTP-Error-400-Bad-request-while-attempting-to-call-create/m-p/162282#M5638</link>
      <description>&lt;P&gt;Ok, I fixed my code to be able to read 'the body of the response' by performing a cast from the vb exception class. What I've got is this:&lt;/P&gt;
&lt;P&gt;"Error in call to API function "sharing/create_shared_link_with_settings": This function requires its argument in the HTTP request body, but your request body is empty."&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2016 02:58:31 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/HTTP-Error-400-Bad-request-while-attempting-to-call-create/m-p/162282#M5638</guid>
      <dc:creator>requiencat ..</dc:creator>
      <dc:date>2016-03-17T02:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: 'HTTP Error 400 Bad request' while attempting to call 'create_shared_link_with_settings' Dropbox api from vb .net for windows desktop app</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/HTTP-Error-400-Bad-request-while-attempting-to-call-create/m-p/162283#M5639</link>
      <description>&lt;P&gt;That error indicates that your request body was empty, instead of containing the parameters. You'll need to debug&amp;nbsp;the code that makes the request to check why your data isn't&amp;nbsp;getting sent up in the body.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2016 03:40:53 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/HTTP-Error-400-Bad-request-while-attempting-to-call-create/m-p/162283#M5639</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-03-17T03:40:53Z</dc:date>
    </item>
  </channel>
</rss>

