LeeB
(Lee Burns)
October 6, 2020, 11:34pm
1
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?
Olga
(Olga Klimova)
October 7, 2020, 12:07am
2
You should send special header with your request. It is called License Header, check REST docs
See also this thread and its link.
We are using e10 rest apis. We use basic auth for authentication, and it’s working well. Although, in E9 we used soap apis and we configured a specific account to use a web service type license, but in e10 rest apis I’m unsure how to specify that we want to use a web service license. I read a bit about epicor sessions, reservations, etc and felt even more confused, my guess is this doesn’t apply to rest apis…?
How do we specify that we want to use a web service license in e10 for rest api calls…
Working on an integration where I need to pass in a specific license and I couldn’t find all the license types, so I did some reflecting and created this basic static class.
@Staci_Stahr_Cummings is this documented anywhere? I couldn’t find it if we want to use a special license CRM, Web Service etc with our integration point we need to know the license type GUID to use it.
public static class EpicorLicenseType
{
public static readonly Guid Default = new Guid("00000003-B615-4300-9…
1 Like
LeeB
(Lee Burns)
October 12, 2020, 12:17am
4
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?
Olga
(Olga Klimova)
October 12, 2020, 1:41am
5
Yes, similar to how you send CallSettings. Just another header.
How do you send CallSettings now?
LeeB
(Lee Burns)
October 12, 2020, 12:03pm
6
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:
I am using basic authentication. I will try to add CallSettings to my CURLOPT_HTTPHEADER => array(). I will also add my full test code which is working with Company A. The failure happens when I try to change the Postfields to include the companyB.
My full working PHP Code (I’m sure there is some sloppyness in here I apologize):
Function ConnectPilot($order_number) {
ini_set(‘max_execution_time’, 300);
ini_set(‘memory_limit’, ‘1024M’); // or you could use 1G
$auth = base64_encode(“MYUSERNA…
LeeB
(Lee Burns)
October 12, 2020, 12:19pm
8
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?
LeeB
(Lee Burns)
October 12, 2020, 12:41pm
10
$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.
LeeB
(Lee Burns)
October 12, 2020, 12:51pm
12
I will look into that, thank you!
LeeB
(Lee Burns)
October 13, 2020, 10:35pm
13
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