Small mistake , forgot to add ";" , so use this one :

Content-Type: multipart/form-data; boundary=182832622229331 [Whatever
you like]


for content-type =application/x-www-form-urlencoded;  format of data
will change slightly. Check online resource .


Thanks,

On Jan 13, 3:12 pm, ThanderMaX <[email protected]> wrote:
> From pyCurl website it seems like it's similar to WebRequest class
> (http://pycurl.sourceforge.net/)
>
> Above code will send the following code to webserver server :
> (provided socket connected to imgur.com at port 80 )
>
> POST /api/upload.xml HTTP/1.1
>         Host: imgur.com
>         User-Agent: Mozilla/4.0
>         Content-Length: 12345 [Calculate the total string length]
>         Content-Type: multipart/form-data boundary=182832622229331 [Whatever
> you like]
>
> -----------------------------182832622229331
> Content-Disposition: form-data; name="key"
>
> YOUR_API_KEY
> -----------------------------182832622229331
> Content-Disposition: form-data; name="image"; filename="file.png"
> Content-Type: text/html
>
> [YOUR FILE CONTENT , You can change the content-type to base64 to
> upload png binary data]
> -----------------------------182832622229331--
>
> OR this one :
>
> POST /api/upload.xml HTTP/1.1
>         Host: imgur.com
>         User-Agent: Mozilla/4.0
>         Content-Length: 12345 [Calculate the total string length]
>         Content-Type: multipart/form-data boundary=182832622229331 [Whatever
> you like but be sure to change the following]
>
> -----------------------------182832622229331
> Content-Disposition: form-data; name="key"
>
> YOUR_API_KEY
> -----------------------------182832622229331
> Content-Disposition: form-data; name="image"
>
> http://example.com/example.jpg
> -----------------------------182832622229331--
>
> OR you can try "application/x-www-form-urlencoded" also.
>
> On Jan 11, 8:09 pm, papuccino1 <[email protected]> wrote:
>
> > I'm trying to make an Open Source application in WPF using C# for
> > uploading images to Imgur.com
>
> > I've recieved my API key and I'm kind of lost because there is no C#
> > example to learn from. Also, squat documentation.
>
> > Here's the working Python code given from the API website:
>
> > #!/usr/bin/python
>
> > import pycurl
>
> > c = pycurl.Curl()
> > values = [
> >           ("key", "YOUR_API_KEY"),
> >           ("image", (c.FORM_FILE, "file.png"))]
> > # OR:     ("image", "http://example.com/example.jpg";))]
>
> > c.setopt(c.URL, "http://imgur.com/api/upload.xml";)
> > c.setopt(c.HTTPPOST, values)
>
> > c.perform()
> > c.close()
>
> > I have absolutely no idea how to proceed. I downloaded the .NET
> > implementation which are three .dll files and tried adding them to a
> > project but I recieve an error that they are not appropiate COM
> > Components. Who knows what the heck that means. :P
>
> > Can someone give me a little example on how to accomplish that Python
> > code in C#? I'm guessing using HTTPWebRequest, but there are no
> > examples that use an API key anywhere online.
>
> > Thanks,
> > Serg

Reply via email to