Jump to content

Upload image web service in c#


Recommended Posts

Hi, I'm developing an app for a company. So, for the app they want to upload images to prestashop. The problem basically is that I can't manage to do it through web service. I always get an error 66:

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<![CDATA[Unable to save this image]]>

I've tried everything (postman, httpclient, webclient). And the only thing that worked was the library of Prestasharp. HOWEVER, my boss doesn't want to rely on external libraries for the app. (yeah, I don't get it either). Hence, I was wondering if someone could tell me how to upload the image without the library.

For example, the following code does not work, but I think it's right.

string file = @"C:\Users\MyPC\Pictures\Example\50.jpg";
string webAddress = @"http://lantec.soyinformatica.com/api/images/products/1?ws_key=NUZSHHQ1X456IJQDPXY3GUXG2C6AMAV3";

var client = new HttpClient();
var pairs = new List<KeyValuePair<string, string>>
    new KeyValuePair<string, string>("image", file)
var content = new FormUrlEncodedContent(pairs);

MessageBox.Show( client.PostAsync(webAddress, content).Result.ReasonPhrase );

I've seen people all around the forum who complain about the same thing, but no one has ever solved this.


I hope you guys can make it,


Kindest regards

Edited by rubenalb90 (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...