Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF REST service does not work with parameter in URI
    primarykey
    data
    text
    <p>I have a WCF REST service (.NET4).</p> <p>It works fine (browser, ajax call) for calls without parameters but I cannot get it to work with parameters. Neither in the browser nor via an ajax call.</p> <p>My contract:</p> <pre><code>[OperationContract] [WebGet( ResponseFormat = WebMessageFormat.Json, UriTemplate = "knowledgefields")] IEnumerable&lt;cKnowledgeField&gt; GetKnowledgeFields(); [OperationContract] [WebGet( BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, UriTemplate = "knowledgeitems?id={id}")] IEnumerable&lt;cKnowledgeItem&gt; GetKnowledgeItemsByField(string id); </code></pre> <p>My web.config</p> <pre><code>&lt;configuration&gt; &lt;appSettings/&gt; &lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.0"&gt; &lt;assemblies&gt; &lt;add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/&gt; &lt;/assemblies&gt; &lt;/compilation&gt; &lt;/system.web&gt; &lt;system.serviceModel&gt; &lt;standardEndpoints&gt; &lt;webHttpEndpoint&gt; &lt;standardEndpoint name="" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat="Json"/&gt; &lt;/webHttpEndpoint&gt; &lt;/standardEndpoints&gt; &lt;services&gt; &lt;service name="ExpertData.expertREST" behaviorConfiguration="META"&gt; &lt;endpoint address="" bindingConfiguration="webHttpBindingWithJsonP" binding="webHttpBinding" contract="ExpertData.IexpertREST"/&gt; &lt;/service&gt; &lt;/services&gt; &lt;protocolMapping&gt; &lt;add scheme="http" binding="webHttpBinding"/&gt; &lt;/protocolMapping&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="META"&gt; &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /&gt; &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior&gt; &lt;webHttp /&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; &lt;bindings&gt; &lt;webHttpBinding&gt; &lt;binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true"/&gt; &lt;/webHttpBinding&gt; &lt;/bindings&gt; &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" /&gt; &lt;/system.serviceModel&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true"/&gt; &lt;directoryBrowse enabled="true"/&gt; &lt;/system.webServer&gt; &lt;connectionStrings&gt; &lt;add name="FindAnExpertEntities" connectionString="metadata=res://*/ExpertData.csdl|res://*/ExpertData.ssdl|res://*/ExpertData.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=WIN8ATWORK\SQLEXPRESS;initial catalog=FindAnExpert;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&amp;quot;" providerName="System.Data.EntityClient"/&gt; &lt;/connectionStrings&gt; &lt;/configuration&gt; </code></pre> <p>Ajax call:</p> <pre><code> function getKnowledgeItems(id) { return $.ajax({ url: "http://localhost:31634/expertREST.svc/knowledgeitems", dataType: "jsonp" data: { "id" : id + "" } }).then( function( data, textStatus, jqXHR ) { amplify.publish( "knowledgeItemsdata.updated", data ); }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload