The remote server returned an error: (404) Not Found in http://drchrono.com/api/documents/

806 views
Skip to first unread message

erickl...@gmail.com

unread,
May 17, 2016, 5:37:10 PM5/17/16
to drchrono Medical Healthcare API SDK
//I am using c#, trying to upload a pdf document. Can you please provide me an example using c# or correct my code? Thanks in advance.

string url = "http://drchrono.com/api/documents/";

var token = getCurrentToken();

HttpWebResponse response = null;

try
{
// Create the data to send

StringBuilder stringBuilder = new StringBuilder();

var headers = string.Format("{{'Authorization': 'Bearer {0}',}}", token.access_token);

stringBuilder.Append("headers=" + Uri.EscapeDataString(headers));

var data = "{'doctor': 1234,'patient': 5678,'description': 'Short document description here','date': '2014-02-24',}";

stringBuilder.Append("&data=" + Uri.EscapeDataString(data));

var pdfFileText = string.Format("{{'document': {0}}}", System.IO.File.ReadAllText(@"C:\Temp2\pdf_temp.pdf"));

stringBuilder.Append("&files=" + pdfFileText);

// Create a byte array of the data to be sent

byte[] byteArray = Encoding.UTF8.GetBytes(stringBuilder.ToString());

// Setup the Request

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

request.Method = "POST";

request.ContentType = "multipart/form-data";

request.ContentLength = byteArray.Length;

// Write data

Stream postStream = request.GetRequestStream();

postStream.Write(byteArray, 0, byteArray.Length);

postStream.Close();

// Send Request & Get Response

response = (HttpWebResponse)request.GetResponse();

using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{

// Get the Response Stream

string json = reader.ReadLine();

Console.WriteLine(json);

}

}

catch (WebException e)
{
//The remote server returned an error: (404) Not Found.
}

alle...@drchrono.com

unread,
May 18, 2016, 12:12:46 PM5/18/16
to drchrono Medical Healthcare API SDK, erickl...@gmail.com
"All requests must be made using the base URL https://drchrono.com".

It looks like you forgot the s.

erickl...@gmail.com

unread,
May 19, 2016, 11:15:31 AM5/19/16
to drchrono Medical Healthcare API SDK, erickl...@gmail.com
I changed to https, but I am having the same error. Can someone please help?

Denis Malinovskiy

unread,
May 19, 2016, 12:02:56 PM5/19/16
to drchro...@googlegroups.com, erickl...@gmail.com
I wonder if removing the trailing slash will fix the problem.  Can you try https://drchrono.com/api/documents as your URL?

On Thu, May 19, 2016 at 8:15 AM, <erickl...@gmail.com> wrote:
I changed to https, but I am having the same error. Can someone please help?

--
You received this message because you are subscribed to the Google Groups "drchrono Medical Healthcare API SDK" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drchrono-api...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Denis Malinovskiy
Software Engineer, drchrono

erickl...@gmail.com

unread,
May 19, 2016, 12:08:32 PM5/19/16
to drchrono Medical Healthcare API SDK, erickl...@gmail.com
With this fix I get the error: "The remote server returned an error: (415) UNSUPPORTED MEDIA TYPE."
Reply all
Reply to author
Forward
0 new messages