I am trying to upload the image using the webservices and Base64string.
But each time I am trying to upload the image it gives me BAD REQUEST (400) Error.
I have googled much about this, it says error is due to the large amount of data is been passed in request.
So I tried to increase the data length from web.config, but adding this.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<!-- buffer: 64KB; max size: 64MB -->
<binding name="FileTransferServicesBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
transferMode="Streamed" messageEncoding="Mtom" maxBufferSize="65536" maxReceivedMessageSize="67108864">
<security mode="None">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
But still it gives me the error.
here is my function.
[OperationContract]
[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Xml)]
string AddAlbum(string imgstring)
And I am calling this function as follows :-
public string PostRemoteJSON(string strurl, string param)
{
try
{
strurl = "http://mydomain.com/EventService.svc/AddAlbum";
param = "{\"imgstring\":\"BASE64STRINGCONTENT\"}";
WebRequest myWebRequest;
Stream myRequestStream;
StreamWriter myStreamWriter;
WebResponse myWebResponse;
myWebRequest = WebRequest.Create(strurl);
myWebRequest.Method = "POST";
myWebRequest.Timeout = 1000000;
myWebRequest.ContentType = "application/json";
myWebRequest.ContentLength = param.Length;
myRequestStream = myWebRequest.GetRequestStream();
myStreamWriter = new StreamWriter(myRequestStream);
myRequestStream = myWebRequest.GetRequestStream();
myStreamWriter.Write(param);
myStreamWriter.Flush();
myStreamWriter.Close();
myRequestStream.Close();
myWebResponse = myWebRequest.GetResponse();
StreamReader reader = new StreamReader(myWebResponse.GetResponseStream());
return reader.ReadToEnd();
}
catch (Exception ex)
{
return ex.Message;
}
}
Please help me.
Thanks
We were facing the same issue in our project. I assume you were having this issue while debugging your app. It seems like DevServer doesn’t support streamed bindings. If you have already tried to increase quotas and buffers, but it didn’t solve the issue, try to deploy your app in IIS, for us it all works fine in IIS environment.