{{ transformations:constructhttpresponseaction.png}} ====== CONSTRUCT HTTP RESPONSE ====== Category: Transform / Web\\ \\ =====Description===== This action constructs the fields required for an HTTP response of the EasyMorph API Server. A configured connection to an EasyMorph Server space is required. \\ =====Action settings===== ^ Setting ^ Description ^ |Response type|Select the type of response sent to the sender. Options: //Success//, //File download//, //Redirect//, or //Error//.\\ Refer to the tables below for details.| \\ ====Response Type: Success settings==== ^ Setting ^ Description ^ |Response code|Select the response code to include in the response. Options: //200 OK//, //201 Created//, or //204 No Content//. | |Body|Choose the options for the response's Body. Refer to the table below for details.| |Custom headers|Choose the options for custom headers in the response. Refer to the table below for details.| \\ ===Body settings=== ^ Setting ^ Description ^ |Response has no body|Check this if no body will be included in the response.| |Column|Select the dataset column that contains the response body to return.| |Body is|Check this if the response body (Column, selected above) contains more than a simple return value, and select its format. Options: //JSON//, //XML// or //HTML//.| |Specify charset|If "Body is" is checked //on//, select the character set the body uses. Options: //ASCII//, //ANSI (with code page)//, //Unicode//, //Big Endian Unicode//, //UTF-32//, //UTF-7//, or //UTF-8//.| ===Remarks=== If the response body is complex, such as JSON or HTML, and is specified using a column, the column with the response body should be constructed prior to "Construct HTTP response" using actions and functions available in EasyMorph, e.g. the [[transformations:constructjson|"Construct JSON" action]]. \\ ===Custom headers settings=== Enter Header/Value* pairs to include in the response body. * Setting can be specified using a [[:parameters|parameter]].\\ \\ ====Response Type: File download settings==== ^ Setting ^ Description ^ |Server file*|Enter the path (from the root Public folder) and filename of the Server file to be returned. (e.g., "\subfolder\filename" if the file resides in a subfolder)| |Download name|Check and enter a name (including extension) to give the returned file a different filename than the original.| |Delete the file after it was downloaded|Check to remove the file from the Server once it is downloaded.| |When downloading in Web browser|Choose "Save" to have the file downloaded onto the recipient's system. Select "Open in browser tab" to have the contents of the file open in the browser window. (This works for text-based files and images only. All other types will be downloaded, instead).| * Setting can be specified using a [[:parameters|parameter]].\\ \\ ====Response Type: Redirect settings==== ^ Setting ^ Description ^ |Redirect type|Select the redirect code/type to include in the response. Options: //302 Found//, //303 See Other//, //307 Temporary Redirect//,\\ or //308 Permanent Redirect//.| |Redirect URL*|Enter the URL the request sender is redirected to.| * Setting can be specified using a [[:parameters|parameter]].\\ \\ ====Response Type: Error settings==== ^ Setting ^ Description ^ |Response code|Select the error code/type to include in the response. Options: //400 Bad Request//, //401 Unauthorized//, //403 Forbidden//, or //500 Internal Server Error//.| |Include error message|Check this to include a custom error code and message and enter the Error code(s)* and Error message(s)*.| * Setting can be specified using a [[:parameters|parameter]].\\ \\ =====Community references===== [[https://community.easymorph.com/t/how-to-create-api-endpoints-without-coding/4231|How to create API Endpoints]] \\ =====See also===== * [[transformations:incominghttprequest|Incoming HTTP request]]