Example: web_rest | Action Functions |
Sends a REST API request using any method supported by HTTP.
int web_rest( const char *StepName, "URL=<URL>", "Method=<HTML method>", "EncType=<encoding type>","Body=<body of message>" ,"Snapshot=<snapshot file>", [[ITEMDATA [["Name=<name>", "Value|FileName=<value>", ENDITEM,]] ]] [[HEADERS [["Name=<header name>", "Value=<value>", ENDHEADER,]] ]] LAST);
Property Name |
Description
|
---|---|
StepName | The name of the step, as it appears in the graphical script. |
URL | The URL of the REST resource. |
Method |
Any method supported by the HTTP protocol. |
EncType |
The encoding type. For example, multipart/form_data, application/x-www-form-urlencoded, or raw. If the encoding type is raw, a Content-type header is required. Use only with POST, PUT, DELETE, and OPTIONS methods. |
Body | The body of the request. |
itemData | Key-value pairs for the data to be POSTed or for URL parameters. If the value is a literal or parameter, the syntax is Name =<Keyname>, Value = <value expression> . If the value is in a file, the syntax is Name =<Keyname>, FileName = <full path name> . |
headers | Header names and values. |
This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure.
The values of keyword-value pairs can be parameterized. For example, "ALT={altParam}".
The web_rest function is an action function that submits a REST request.
web_rest is not recorded. You can add it manually to a script.
The HTTP header can be modified to pass additional information about the request to the server. Using HTTP headers you can, for example, allow other content types in the response such as compressed files, or you can request a Web page only on certain conditions.
The method can be any method supported by the HTTP protocol. For example:
This is an example of a post:
web_rest("POST: www.mysite.com", "URL=http://www.mysite?ParamKey1=ParamValue1", "Method=POST", "EncType=application/x-www-form-urlencoded", "Snapshot=t782415.inf", ITEMDATA, "Name=Key1", "Value=Value1", ENDITEM, "Name=Key2", "FileName=C:\Program Files (x86)\SAP\FrontEnd\__sap.dir", ENDITEM, HEADERS, Name=Accept", "Value=text/html", ENDHEADER, LAST);