# Pulling data from web via REST BPM

**URL:** <https://www.epiusers.help/t/pulling-data-from-web-via-rest-bpm/81246>\
**Category:** Epicor ERP 10\
**Tags:** rest, bpm\
**Created:** [August 3, 2021, 8:27pm UTC](https://www.epiusers.help/t/pulling-data-from-web-via-rest-bpm/81246 "2021-08-03T20:27:28Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![OnurCam](https://www.epiusers.help/letter_avatar_proxy/v4/letter/o/977dab/32.png) [@OnurCam](https://www.epiusers.help/u/OnurCam)\
**Post date:** [January 27, 2022, 12:34am UTC](https://www.epiusers.help/t/pulling-data-from-web-via-rest-bpm/81246/21 "2022-01-27T00:34:56Z")

</div>

Hey @steveh

Were you able to get your code to work?

I’m having the same issue with Microsoft.CSharp.RuntimeBinder.Binder and I was wondering if you got your solution working after manually bringing in Microsoft.Csharp dll?

Thanks!

---

<div class="post-metadata">

**Author:** ![steveh](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@steveh](https://www.epiusers.help/u/steveh)\
**Post date:** [January 28, 2022, 10:47am UTC](https://www.epiusers.help/t/pulling-data-from-web-via-rest-bpm/81246/22 "2022-01-28T10:47:46Z")

</div>

Yes it works now.

I zipped up the dll and put it in the custom folder on the server and added the appropriate line to the config to deploy it

---

<div class="post-metadata">

**Author:** ![tomdomurat](https://www.epiusers.help/user_avatar/www.epiusers.help/tomdomurat/32/41633_2.png) [@tomdomurat](https://www.epiusers.help/u/tomdomurat)\
**Post date:** [May 17, 2023, 12:49pm UTC](https://www.epiusers.help/t/pulling-data-from-web-via-rest-bpm/81246/23 "2023-05-17T12:49:01Z")

</div>

I am tying to call a Function from Custom Code and followed the Help documentation, but I cannot get it to work. The code compiles in the Code Editor. I know the Function is working because I can call it from a Data Directive.

This is the error:  
Exception caught in: Epicor.Ice.Lib.RestClient

# Error Detail

Description: Cannot perform runtime binding on a null reference

This is the Code:

```
		string restApiKey = "";
	    string libraryName = "PartWebService";
	    string functionName = "PartSearch";
		string part = ""; 		

		var functionInputParameters = new RestContent(
	    new
	    {
	        part= "xyz"
	    });
		MessageBox.Show(this.txtUBIC.Text);
		var getByIdParameters = new RestContent(new{ part = part});

		var restClient = new RestClientBuilder()
    		.SetDefaultApiKey(restApiKey)
    		.UseSession(oTrans.CoreSession)
    		.Build();

		var response = restClient.Function.Post(libraryName, functionName, getByIdParameters, published: true);    
		dynamic responseJson = response.GetJsonResult();
		if (responseJson != null)
		{
			MessageBox.Show("JSON response.");
			var functionResult = response.GetJsonResult();
    		DataSet resultDS = Newtonsoft.Json.JsonConvert.DeserializeObject<DataSet>(responseJson["result?"].ToString());
			//DataSet resultDS = JObject.Parse(json)["result?"].ToObject<DataSet>();
			eugUBICResult = (EpiUltraGrid)csm.GetNativeControlReference("ed79ae21-fe97-4624-b030-2224b4123cea");
			eugUBICResult.DataSource = resultDS;
			eugUBICResult.DataBind();
		}
		else
		{
			MessageBox.Show("JSON returned error.");
		}

```

---

<div class="post-metadata">

**Author:** ![steveh](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@steveh](https://www.epiusers.help/u/steveh)\
**Post date:** [May 17, 2023, 3:40pm UTC](https://www.epiusers.help/t/pulling-data-from-web-via-rest-bpm/81246/24 "2023-05-17T15:40:38Z")

</div>

I have built the rest connection a little differently because we are using SSO but here is what I have done.

Presumably you are passing an API Key and not passing it in blank as per your code snippet?

 ![image](https://www.epiusers.help/uploads/default/original/3X/e/d/ed6f81e2633dbc5570970a52e6cf20a18d47a914.png)

---

<div class="post-metadata">

**Author:** ![steveh](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@steveh](https://www.epiusers.help/u/steveh)\
**Post date:** [May 17, 2023, 3:41pm UTC](https://www.epiusers.help/t/pulling-data-from-web-via-rest-bpm/81246/25 "2023-05-17T15:41:02Z")

</div>

var restClient = new RestClientBuilder().SetAppServerUrl(this.oTrans.CoreSession.AppServer).SetCompanyId(this.oTrans.CoreSession.CompanyID).SetDefaultApiKey(ApiKey).SetIsSingleSignOn(true).Build();

---

<div class="post-metadata">

**Author:** ![tomdomurat](https://www.epiusers.help/user_avatar/www.epiusers.help/tomdomurat/32/41633_2.png) [@tomdomurat](https://www.epiusers.help/u/tomdomurat)\
**Post date:** [May 17, 2023, 5:18pm UTC](https://www.epiusers.help/t/pulling-data-from-web-via-rest-bpm/81246/26 "2023-05-17T17:18:36Z")

</div>

I took that code snippet verbatim from the Epicor Help – Calling Functions from Custom Code. I do an Epicor Application Event Log and it is triggering the Function, but something else is wrong. Whether I specify a blank API Key or this one in API Key Maintenance. I still get the error.

Server Side Exception

Cannot perform runtime binding on a null reference

Exception caught in: Epicor.Ice.Lib.RestClient

# Error Detail

Description: Cannot perform runtime binding on a null reference

Correlation ID: 1a93f4e2-6b3e-4cf9-9c31-0ad0b7f57c92

# Client Stack Trace

at Ice.Lib.RestClient.ResilientCaller.d\_\_10.MoveNext()  
— End of stack trace from previous location where exception was thrown —  
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)  
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)  
at Ice.Lib.RestClient.ResilientCaller.d\_\_6.MoveNext()  
— End of stack trace from previous location where exception was thrown —  
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()  
at Ice.Lib.RestClient.AsyncToSyncHelper.DoSynchronous[TResult](Task`1 task) at Ice.Lib.RestClient.RestClient.Ice.Lib.RestClient.IRestFunctionCaller.Post(String library, String function, RestContent content, Boolean published, IEnumerable`1 headers)  
at Script.btnGetUBICData\_Click(Object sender, EventArgs args)  
at System.Windows.Forms.Control.OnClick(EventArgs e)  
at Infragistics.Win.Misc.UltraButtonBase.OnClick(EventArgs e)  
at Ice.Lib.Framework.EpiButton.OnClick(EventArgs e)  
at Infragistics.Win.Misc.UltraButton.OnMouseUp(MouseEventArgs e)  
at Ice.Lib.Framework.EpiButton.OnMouseUp(MouseEventArgs e)  
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)  
at System.Windows.Forms.Control.WndProc(Message& m)  
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)  
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)  
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 ![image](https://www.epiusers.help/uploads/default/original/3X/d/6/d6305f9bf6ef3a59e01cab011b44f0598b34ef19.png)

[Previous page](https://www.epiusers.help/t/pulling-data-from-web-via-rest-bpm/81246.md?page=1)
