E10 Web Service License for oData Calls

I’m using php’s file_get_contents(“https://apache:password@server/epicorlive10/api/v1/BaqSvc/CompanyBAQ\”) to list data from a BAQ into my webpage.

The problem is that it consumes a standard user license each time the call is made. We bought some Web Service licenses, and I can’t figure out where to apply the change to have REST services use those licenses instead.

I’ve googled around, and it looks like this is a server level change in Vantage 9, but I can’t find related E10 information. The technical reference guide for 10.2.400 isn’t clear from what I’ve seen.

Does anyone have any thoughts on how I might accomplish this?

You should send special header with your request. It is called License Header, check REST docs

See also this thread and its link.

1 Like

Do you know if this is done through the CURLOPT_HTTPHEADER if I’m using PHP/CURL? Kind of the way I’m submitting my second company through the CallSettings in the same header?

Yes, similar to how you send CallSettings. Just another header.
How do you send CallSettings now?

I throw it into a variable array I call $headers

	$headers = array('Content-Type: application/json'
				    ,'CallSettings: {"Company": "'.$epicor_company.'"}');

Then I use the CURL Set Option to pass that array into CURLOPT_HTTPHEADER:

    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

I tried building this into the HTTPHEADER, but I just couldn’t get any valid responses:

'License: {"ClaimedLicense": "00000003-9439-4B30-A6F4-6D2FD4B9FD0F"}'

How might you go about it? Thanks for your insight!

Searching this site with “curl REST header” returns this as one of the results:

Thanks Mark. That’s the result that ultimately pointed me to the CallSettings to switch companies within my web service. However, I’m trying to figure out which header/syntax to use to send in the License Selection to grab our Web Service licenses.

Can you post your whole Headers code?

$headers = array('Content-Type: application/json'
				,'CallSettings: {"Company": "'.$epicor_company.'"}'
				,'License: {ClaimedLicense: "00000003-9439-4B30-A6F4-6D2FD4B9FD0F"}'
				);

Well, I just tried the header above and it looks like it actually worked. I can’t refresh the Admin console fast enough to see that a WebService license was used, but I could run a trace to verify it.

2 Likes

You could use the SessionModSvc to get the same list of active sessions through REST instead of the Admin Console.

I will look into that, thank you!

I got it working both with CURL and file_get_contents. For anyone looking for php breadcrumbs in the future, here are some working examples:

(Where “00000003-9439-4B30-A6F4-6D2FD4B9FD0F” is the specific GUID for Web Service Licenses)

CURL Headers:

$headers = array('Content-Type: application/json'
				,'CallSettings: {"Company": "'.$epicor_company.'"}'
				,'License: {"ClaimedLicense": "00000003-9439-4B30-A6F4-6D2FD4B9FD0F"}'
				);//GUID is for WebService License

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $epicorURL);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($curl, CURLOPT_POSTFIELDS, $epicorJSON);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

file_get_contents headers:

  $opts = array(
  	"http" => array(
  	
  		"method" => "GET",
  		"header" => "Accept-language: en\r\n"
  				  . "License: {\"ClaimedLicense\": \"00000003-9439-4B30-A6F4-6D2FD4B9FD0F\"}\r\n"
  	)
  
  );
  
  $context = stream_context_create($opts);
  $response = json_decode(file_get_contents($oDataURL, false, $context), true);
3 Likes