Click here to Skip to main content
15,889,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a WCF Rest service that is making a call to a remote server. The service sends some of the parameters as Query parameters (dynamic) and some as static. The static parameters are already configured in web.config as appkeysettings :

<appsettings>
<add key="importfolderpath" value="C:/Users/preprod/Documents/FlexCBS/Import">
<add key="securitytoken" value="45e29ad9-3a41-4203-8a24-43ee6a7d6aaf">



When i attempt to invoke the request in Postman i get '400 Bad Request' . I have since realised i need to encode part of the request that contains a slash:

{
"MediaReference": “HRE/MVE/Q/000003276”
}


The original endpooint is :

C#
[OperationContract]
      [WebInvoke(Method = "GET", UriTemplate = "/FlexcubeConfirmationWraped?MediaReference={MediaReference}&BankAccountCode={BankAccountCode}&BillRefNumber={BillRefNumber}&MediaTypeCode={MediaTypeCode}&CurrencyCode={CurrencyCode}&Reference={Reference}&Amount={Amount}", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
      string FlexcubeTransactionConfirmationWraped(string MediaReference, string BillRefNumber,string Amount, string BankAccountCode, string CurrencyCode, string Reference, string MediaTypeCode);




Am i doing this correct ? Any help on how i can encode a certain part of UriTemplate

What I have tried:

I have tried encoding the request below but im getting a syntax error at this comma immediately before BodyStyle


C#
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "/FlexcubeConfirmationWraped?BankAccountCode={BankAccountCode}&BillRefNumber={BillRefNumber}&MediaTypeCode={MediaTypeCode}&CurrencyCode={CurrencyCode}&Reference={Reference}&Amount={Amount}"  + HttpUtility.UrlEncode("MediaReference") +  ,BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string FlexcubeTransactionConfirmationWraped(string MediaReference, string BillRefNumber,string Amount, string BankAccountCode, string CurrencyCode, string Reference, string MediaTypeCode);
Posted

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