Skip to content

GET/Query Request Samples

The three GET samples have the same shape. They accept the request, query the Sage database for the caller's orders, shape the rows into orders and lines, and write the result back to the client as JSON.

Five boxes in a row: a WebAPI Reader to accept the request, standard transform logic, a database read of the orders from the Sage 300 database, a hierarchy and map to shape the data for the response, and a JSON writer to write the orders back to the client

Making the Request

Url

The route takes two parameters, a location in the path and a start date in the query string, which the integration uses to limit the orders returned.

Postman's request line: GET http://localhost/IManWebAPI/sage300orders/4?startDate=2026-08-01, with the Params tab showing the startDate query parameter

Route location startDate Example
Sage 200 sage200orders/{location}?startDate={startDate} a warehouse name the earliest document date, yyyy-MM-dd http://localhost/IManWebAPI/sage200orders/NEWCASTLE?startDate=2022-01-01
Sage 300 sage300orders/{location}?startDate={startDate} a location id the earliest order date, yyyy-MM-dd http://localhost/IManWebAPI/sage300orders/4?startDate=2026-08-01
Sage X3 sagex3orders/{location}?startDate={startDate} a shipping site id the earliest order date, yyyy-MM-dd http://localhost/IManWebAPI/sagex3orders/FR003?startDate=2022-01-01

Authorisation

Every sample endpoint requires authentication. Set the request's authorisation to Basic Auth, with the username and password of the sample web user for the endpoint.

Postman's Authorization tab with Type set to Basic Auth, Username sage300 and the password hidden

Web User Setup

The Edit Web User dialog for SAGE300: Http Authentication Type Basic Authentication, the User Token, Username sage300, and Enabled ticked

Headers

Two request headers complete the request.

Postman's Headers tab with the two headers Debug, True, and X-User-Token, holding the web user's token, beneath the headers Postman adds itself. A callout marks the two

X-User-Token

The web user's User Token, from its setup. The username in the Authorization header and this token must belong to the same user; the token finds the user, and the username and password authenticate it.

Debug

True routes the request to the Designer, where the reader's Refresh Schema picks it up. False, or no Debug header at all, runs the integration.

Integration Design

WebAPI Reader

The WebAPI Reader accepts the request and presents it as one record, whose fields the Database Reader below uses.

Parameters

The route's two parameters arrive as Http.Param.location and Http.Param.startDate.

The WebAPI reader's Field Mapping tab listing the Http fields of the request, with Http.Param.startDate and Http.Param.location among them, beside the preview record holding their values

User Property

The caller's property values arrive as Http.User.<property> fields. The sample property set maps each web user to its customer account, so Http.User.Sage300CustID is the customer whose orders the Sage 300 sample returns, and the caller cannot ask for anyone else's.

The preview record scrolled to its last columns: Http.User.UserId SAGE300, Http.Content, and the three property fields Http.User.Sage300CustID, Http.User.Sage200CustID and Http.User.SageX3CustID

Map Transform

Validate what the client sent before using it. The Check function is the way: it stops the integration with an error code, and the WebAPI returns that code as the response's status.

Each sample checks startDate is a date, answering 400 otherwise, and converts it to the form the database needs. The Sage 300 sample also checks location against a lookup of the company's locations, answering 422 when it is not one.

Dim Valid

Valid = Check(IsDate(%Http.Param.startDate), 400, "startDate is not valid. Please submit in yyyy-MM-dd format.")

Format(CDate(%Http.Param.startDate), "yyyyMMdd")

The Field Mapping dialog for Http.Param.startDate with Evaluate ticked and the Check formula in the editor

Database Reader

The Database Reader queries the orders. The parameterisation is the where clause, which takes the customer from the user property and the location and start date from the request.

select ORDNUMBER, ORDDATE, REFERENCE, H.LOCATION, ITEM, QTYORDERED, PRIUNTPRC, D.[DESC]
from OEORDH H
inner join OEORDD D on H.ORDUNIQ = D.ORDUNIQ
where H.CUSTOMER = %Record.Http.User.Sage300CustID
and ORDDATE > %Record.Http.Param.startDate
and H.LOCATION = %Record.Http.Param.location

The Database Reader's Setup tab with the SQL statement above in its SQL Statement box

Hierarchy & Map

The Hierarchy transform turns the flat rows into orders with their lines. The Map after it tidies the values: the order date to a date, the quantity to a whole number, the price to two decimals.

JSON Writer

The writer's Target is WebAPI, which routes its output back to the client as the response.

The JSON Writer's Setup tab with Target set to WebAPI and, beneath it, the line naming the endpoint

Output

The response is the caller's orders since the start date, at the location. While designing, produce it with the steps under Sending the Response.

Postman's response pane showing 200 OK and a JSON body of orders, each with its order number, date, warehouse and line items