0
My code makes a webapi post from a trigger in an SP that monitors my database.
This POST works well for msgs of up to 4000 characters but above that the SP gives this error:
"ERROR -> 9521 exceeds maximum accepted message size of 4,000."
SP:
CREATE PROCEDURE TESTE_SP_TransactionNotification
@object_type nvarchar(20),
@transaction_type nchar(1),
@list_of_key_cols_tab_del nvarchar(max),
@list_of_cols_val_tab_del nvarchar(max),
@ErrorNumber int output,
@ErrorDescription nvarchar(4000) output
as EXTERNAL NAME [Xnet.Atelie.Integration.Clr].
[Clr.StoredProcedures].[TESTE_SP_TransactionNotification]
Code POST . NET
protected string POST([SqlFacet(MaxSize = -1)]string message, string url, string routerKey)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
SqlContext.Pipe.Send("Send::: " + message);
var messageBytes = Convert.ToBase64String(Encoding.UTF8.GetBytes(message));
var send = "{\"exchange\":\"" + this.Exchange + "\", \"routerKey\":\"" + routerKey + "\", \"content\": \"" + messageBytes + "\" }";
SqlContext.Pipe.Send(send);
request.ContentType = "application/json";
request.ContentLength = Encoding.UTF8.GetBytes(send).Length;
using (var dataStream = request.GetRequestStream())
{
dataStream.Write(Encoding.UTF8.GetBytes(send), 0, Encoding.UTF8.GetBytes(send).Length);
dataStream.Close();
using (var response = (HttpWebResponse)request.GetResponse())
{
SqlContext.Pipe.Send(response.StatusDescription);
var responseFromServer = response.StatusDescription;
response.Close();
SqlContext.Pipe.Send(responseFromServer);
return responseFromServer;
}
}
}