Reputation: 125
Here is the code below
I tried this call but it didnt work... even if the function inside this call is empty i tried this exact function call with only 5 input parameters and it worked? Something is fishy here hopefully someone can suggest and if you have anyway i can minimize this code meaning the parameters passes im open for suggestions anytime.
Code below:
[WebInvoke(UriTemplate = "customer/update/customerCode={customerCode}/customerName={customerName}/customerCountry={customerCountry}/customerTelephone={customerTelephone}/customerEmail={customerEmail}/customerCreditLimit={customerCreditLimit}/customerCommission={customerCommission}/customerRank={customerRank}/contactFullname={contactFullname}/contactBusinessPhone={contactBusinessPhone}/contactTimezone={contactTimezone}/contactActive={contactActive}/contactDepartment={contactDepartment}/contactHomePhoneExtension={contactHomePhoneExtension}/shipToCountry={shipToCountry}/shipToPaymentTerm={shipToPaymentTerm}/shipToCommissionPercent={shipToCommissionPercent}/shipToTruckSize={shipToTruckSize}/shipToTaxNumber={shipToTaxNumber}/shipToRouteCode={shipToRouteCode}/shipToOpenTime={shipToOpenTime}/shipToCloseTime={shipToCloseTime}", Method = "PUT", BodyStyle = WebMessageBodyStyle.Wrapped)]
public void UpdateCustomer(string customerCode, string customerName, string customerCountry, string customerTelephone, string customerEmail,
string customerCreditLimit, string customerCommission, string customerRank, string contactFullname,
string contactBusinessPhone, string contactTimezone, string contactActive, string contactDepartment,
string contactHomePhoneExtension, string shipToCountry, string shipToPaymentTerm, string shipToCommissionPercent,
string shipToTruckSize, string shipToTaxNumber, string shipToRouteCode, string shipToOpenTime,
string shipToCloseTime)
{
// code or no code
}
This is how I implement the function above:
using (HttpResponseMessage response = m_RestHttpClient.Put("customer/update/customerCode=CUST190/customerName=Ralph Lauren/customerCountry=United Kingdom/customerTelephone=1234567489/[email protected]/customerCreditLimit=1/customerCommission=5/customerRank=45/contactFullname=Diego Sin/contactBusinessPhone=911/contactTimezone=6/contactActive=True/contactDepartment=Sales/contactHomePhoneExtension=456/shipToCountry=Uganda/shipToPaymentTerm=NET30/shipToCommissionPercent=1/shipToTruckSize=50/shipToTaxNumber=777/shipToRouteCode=001/shipToOpenTime=10 am/shipToCloseTime=11pm", frm.CreateHttpContent()))
{
response.EnsureStatusIsSuccessful();
}
Thanks
Upvotes: 1
Views: 543
Reputation: 142252
You don't have a body parameter, PUT requires a body.
Beyond that, PUT is not equivalent to doing an Update stored procedure. Don't try and do this, it does not make any sense. All those parameters need to go in the body.
There are physical limits to URL length, so you may be running into an issue because of that.
Upvotes: 2