Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I have used the following code to send the file using multipart post and i am getting the responsecode as 500 pl tell me what is wrong in my code
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CodeScales.Http;
using CodeScales.Http.Methods;
using CodeScales.Http.Entity;
using CodeScales.Http.Entity.Mime;
using CodeScales.Http.Common;
using System.IO;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpClient ht = new HttpClient();
        HttpClient client = new HttpClient();
        HttpPost postMethod = new HttpPost(new Uri("http://www.inspire-geoportal.eu/INSPIREValidatorService/resources/validation/inspire"));
        postMethod.Headers.Add("Authorisation", "text/html");
        MultipartEntity multipartEntity = new MultipartEntity();
        FileInfo fileInfo = new FileInfo(@"C:\Users\10033\Desktop\WebService\Metadata_test_Inspire_DM_MedYttäckning _och_Överensst_true_ISO19139.xml");
        FileBody fileBody = new FileBody("Metadata_test_Inspire_DM_MedYttäckning _och_Överensst_true_ISO19139", "Metadata_test_Inspire_DM_MedYttäckning _och_Överensst_true_ISO19139.xml", fileInfo);
        StringBody stringBody = new StringBody(Encoding.UTF8, "Metadata_test_Inspire_DM_MedYttäckning _och_Överensst_true_ISO19139.xml", "text/html");
        multipartEntity.AddBody(stringBody);
        postMethod.Entity = multipartEntity;
        multipartEntity.IsChunked = true;
        postMethod.Entity.IsChunked = true;
        //multipartEntity.AddBody(fileBody);
        CodeScales.Http.Methods.HttpResponse response = client.Execute(postMethod);
        Response.Write(EntityUtils.ToString(response.Entity));
        Console.WriteLine("Response Code: " + response.ResponseCode);
        Console.WriteLine("Response Content: " + EntityUtils.ToString(response.Entity));
    }
}
Posted
Updated 2-Nov-11 2:39am
v2

1 solution

Response Code 500 represents "InternalError". That means something has exception out from your REST Service.

Try by calling your REST Service in "Fiddler", it may provide you some additional Error Details.
http://www.fiddler2.com/fiddler2/
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900