1

I am trying to upload my images to deviantart

They give below curl command as example to upload stash

I got my access_token already however i don't know how can i post this with either using asp.net or C#

Help is appreciated

I need to upload image along with parameters

Here the curl command they gave as example

 curl https://www.deviantart.com/api/v1/oauth2/stash/submit \
-F "title=My great stash item&artist_comments=This is a great image&keywords=test image" \
-F access_token=Alph4num3r1ct0k3nv4lu3 \
-F "test=@path/to/image.png" 

c# .net 4.5

1 Answer 1

1

You can send a POST request using WebClient like following.

using (var webcl = new WebClient())
{
    var inputdata = new System.Collections.Specialized.NameValueCollection();
    inputdata["title"] = "My great stash item";
    inputdata["artist_comments"] = "This is a great image";
    inputdata["keywords"] = "test image";
    inputdata["access_token"] = "Alph4num3r1ct0k3nv4lu3";
    inputdata["test"] = "path/to/image";

    var output = webcl.UploadValues("https://www.deviantart.com/api/v1/oauth2/stash/submit", "POST", inputdata);
}

However, when i tried this, I got 401 unauthorized error. Might be access_token got expired.

Because when i tried samething with curl,i also got following error.

{"error":"invalid_token","error_description":"Expired oAuth2 user token. The cli ent should request a new one with an access code or a refresh token.","status":" error"}

Sign up to request clarification or add additional context in comments.

4 Comments

ty very much gonna try yes it requires access token :D
ok this failed. because i am supposed to post image data as well. this doesn't post image ? it says 400 bad request . that test parameter need to be image
@MonsterMMORPG, can you try using some publicly hosted image path there, like ` inputdata["test"] = "https ://ssl.gstatic.com/gb/images/i1_71651352.png"`.
well publicly hosted would not work for me i have to upload from my computer 1000+ images. with free curl this job is super easy but i am shocked .net does not have proper handling classes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.