Testing REST SalesOrders service with POSTMAN

I’m trying to test out this service with POSTMAN: https:/xxxx-epicor10/E10Train/api/v1/Erp.BO.SalesOrderSvc/SalesOrders

If I don’t add parameters I get all the data returned. When I add parameters company and ordernum both of which exist in the TRAIN environment, it says “Sorry Something went wrong.”

What am I doing wrong in POSTMAN? Even the Swagger try it out has the same error.

you need to turn off custom errors so you can see what the actual error is… its the web.config otherwise look in the event viewer in the server to see the error.
My gut says its saying “Record Not Found” (which GetByID returns if the record isn’t found)

I’ll give it a try but where can we find web.config ?

The server deployment folder (IIS) depends on where you deployed your app server to… something like this

Okay I found the web.config file it looks like it’s xml.

I see this from a previous post you created:

 <system.web>
   <customErrors mode="Off" />
  </system.web>

But where in the web.config file does that go? Between which tags? Or outside all of them? There is already a <system.webServer> section should it go there?

Do I have to restart IIS after that’s completed?

at the bottom inside the but outside any other tag… If the system.web already exists… then it goes in there. <system.webServer> is NOT the same thing.

So I’m trying it with the Swagger tool and It looks like the service is completely ignoring the company and defaulting to one company and only that company.

We have two companies in our database but it’s only finding orders for the first.

This seems like a bug. What could be the reason for this behavior?

COmpany is set via callContextHeader and you can’t do that in swaggger

I think I got it to work in POSTMAN and in a PHP CURL call.

None of this stuff is straight forward and better yet it’s not documented on the swagger. callContextHeader seems to be required to set the company.

The company in the URL doesn’t do anything yet needs something to be populated in it (counter-intuitive and confusing IMO).

In case anyone is looking for how to do it in PHP with CURL (EDIT the following PHP code was fixed with information from replies later in this thread and is good to run)

//Authorization is the base64 encoded string of "username:password"
		$auth = base64_encode("manager:manager");                      

	//Start CURL
		$curl = curl_init();

	//Set CURL Options
		curl_setopt_array($curl, array(
			CURLOPT_URL => "https://xxxx-epicor10/E10Train/api/v1/Erp.BO.SalesOrderSvc/SalesOrders(SD,400142)",
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_SSL_VERIFYPEER => false,
			CURLOPT_SSL_VERIFYHOST =>false,
			CURLOPT_ENCODING => "UTF-8",
			CURLOPT_MAXREDIRS => 10,
			CURLOPT_TIMEOUT => 30,
			CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
			CURLOPT_CUSTOMREQUEST => "GET",
			CURLOPT_POSTFIELDS => "",
			CURLOPT_HTTPHEADER => array(
				"Authorization: Basic " . $auth,
				"Cache-Control: no-cache",
				"Content-Type: application/json",
				"CallSettings: {'Company':'AB','Plant':'MfgSys','Language':'','FormatCulture':'' }"
			),
		));

	//Run CURL
		if ( !$c_response = curl_exec($curl) ) {
		//CURL error
			echo curl_error($curl);
		} else {
		//CURL success
			echo $c_response;				
		}			

	//Close CURL
		curl_close($curl);

Hmm actually that callContextHeader you are passing isn’t a valid header. Not sure why it now “works” for you if I had to venture a guess is you logged in into Epicor and changed to that company so your session got updated.
The actual Header you need to send is CallSettings as documented here

There is a lot of stuff documented, here on the forum and on Epicor Help and on the various Guides.

IF you haven’t done so I recommend a thorough browsing of the “Experts Corner” in this forum as well as looking at the documentation SWAGGER, the Epicor Help Regarding REST, EpicWeb Documentation such as the Customization Guide and Exprience User Guide as well as the Web Services Technical Reference.

COmpany is set via callContextHeader

What is callContextHeader then? Did you mean CallSettings? Sorry to ask but these terms are all brand new for me and I’m a little out of my depth here.

Also to anyone from Epicor: why would the swagger documentation say it’s called like this: https://xxxx-epicor10/E10Train/api/v1/Erp.BO.SalesOrderSvc/SalesOrders(SD,60001) <-with company & OrderNum required but that’s not where it’s actually getting the company value from? Is that an oversight?

Bart_Elia even says it in his REST Overview Novel:

The documentation seems incomplete to say that that’s where you enter the company yet it plays no part in the actual request but yet the request will fail without something there. More importantly do other services act the same way?

Maybe a note inside the swagger to mention that CallSettings must be set to select the correct company would be good?

I found the call settings under help now that it was pointed out that those are needed but I’m not sure I would have known without this forum’s help … so thank you for all your help thus far.

It was a typo. It should be CallSettings