Hi, I got some trouble with passing parameters through the web api to invoke the custom action. I am following this article (https://msdn.microsoft.com/en-us/library/mt742426.aspx) but still confused. Basically, I need pass 3 parameters, where should I call the action in the uri ?
public async Task TestActionAsync() { Console.WriteLine("--Action Test Starts Here--"); Money amount = new Money() { Value = 300 }; JObject exeAction = JObject.Parse(@"{ApplicationRef: '8B446743-C6C4-E711-A81C-005056B5FEFA','Amount:"+amount+"',Authcode:'0001'}"); string actionUri =(how to define the URI) response = await SendAsJsonAsync(httpClient, HttpMethod.Post, actionUri, exeAction); }
*This post is locked for comments
I got this error
The uri is not correct. try this
dev-hq.reco.on.ca/.../Microsoft.Dynamics.CRM.recoserv_ACT101_Payment_MarkAsPaid
Hi, Nuno,
I still got syntax error message, please check
public async Task TestActionAsync() { Console.WriteLine("--Action Test Starts Here--"); JObject exeAction = new JObject(); exeAction["ApplicationRef"] = "8B446743-C6C4-E711-A81C-005056B5FEFA"; exeAction["Amount"] = new Money(){ Value = 300 }.Value; exeAction["Authcode"] = "0001"; string actionUri = "dev-hq.reco.on.ca/.../(05AD4D28-58C6-E711-A81D-005056B5FEFA)Microsoft.Dynamics.CRM.recoserv_ACT101_Payment_MarkAsPaid"; HttpResponseMessage response = await SendAsJsonAsync(httpClient, HttpMethod.Post, actionUri, exeAction); if (response.StatusCode == HttpStatusCode.OK) { Console.WriteLine("Successful"); } else { Console.WriteLine("fail to call the action"); throw new CrmHttpResponseException(response.Content); } } private async Task<HttpResponseMessage> SendAsJsonAsync<T>(HttpClient client, HttpMethod method, string requestUri, T value) { string content; if (value.GetType().Name.Equals("JObject")) { content = value.ToString(); } else { content = JsonConvert.SerializeObject(value, new JsonSerializerSettings() { DefaultValueHandling = DefaultValueHandling.Ignore }); } HttpRequestMessage request = new HttpRequestMessage(method, requestUri); request.Content = new StringContent(content); request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); return await client.SendAsync(request); }
If the action is global then
string actionUri = "recoserv_ACT101_Payment_MarkAsPaid";
If the action is bound to an entity then
string actionUri = "dev-hq.dev.com/.../" + entitylogicalname + "(" + guid_entity_record + ")" + "/Microsoft.Dynamics.CRM.recoserv_ACT101_Payment_MarkAsPaid"
for example, if the action is bound to account entity and there is an account record with next guid, the uri would be
string actionUri = "dev-hq.dev.com/.../Microsoft.Dynamics.CRM.recoserv_ACT101_Payment_MarkAsPaid"
Hi, Nuno,
the actionUri should be the url+action name, right? I tried in this way, but I got the error message that " resource not found for the segament"
public async Task TestActionAsync() { Console.WriteLine("--Action Test Starts Here--"); JObject exeAction = new JObject(); exeAction["ApplicationRef"] = "8B446743-C6C4-E711-A81C-005056B5FEFA"; exeAction["Amount"] = new Money(){ Value = 300 }.Value; exeAction["Authcode"] = "0001"; string actionUri = "dev-hq.dev.com/.../Microsoft.Dynamics.CRM.recoserv_ACT101_Payment_MarkAsPaid"; HttpResponseMessage response = await SendAsJsonAsync(httpClient, HttpMethod.Post, actionUri, exeAction); if (response.StatusCode == HttpStatusCode.OK) { Console.WriteLine("Successful"); } else { Console.WriteLine("fail to call the action"); throw new CrmHttpResponseException(response.Content); } }
Hi,
JObject exeAction = new JObject();
exeAction["ApplicationRef"] = "8B446743-C6C4-E711-A81C-005056B5FEFA";
exeAction["Amount"] = new Money() { Value = 300 };
exeAction["Authcode"] = "0001";
string actionUri = "ACTION_NAME";
response = await SendAsJsonAsync(httpClient, HttpMethod.Post, actionUri, exeAction);
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156