Create HTTP Content
Verb: createHttpContent
Creates a variable that stores the contents and headers of one or more HTTP messages
Syntax
createHttpContent --formattype(Nullable<HttpFormatter>) [--boundary(String)] [--contentheader(String)] [--body(String)] [--parameters(String)] [--encoding(Nullable<EncodingType>)] [--mediatype(String)] --file(String) [--contentlist(String)] (HttpContent)=value
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--formattype | Formatter | Required | HttpFormatter | Body formatter, with available options:
|
--boundary | Boundary | Optional | Text | Text used to separate different HTTP messages. |
--contentheader | Content Headers | Optional | Text | Content headers with information from the request. |
--body | Body | Optional | Text | Formatted text that should be sent in the body of the request. |
--parameters | Parameters | Optional | Text | Parameters that should be sent in the body of the request. |
--encoding | Encoding | Optional | EncodingType | Text encoding. Options:
|
--mediatype | Media Type | Optional | Text | Media type of the text. |
--file | File | Only whenFormatter is Bytes | Text | File that should be sent. |
--contentlist | Contents | Optional | Text | Mappings of HTTP messages to be used. |
Outputs
Script | Designer | AcceptedTypes | Description |
---|---|---|---|
value | Content | Http Content | Returns the content of the HTTP message. |
Example
Creates different HTTP messages, storing all of them in one variable and executes POST method request, instancing different messages to perform the requests.
defVar --name content --type HttpContent
defVar --name multicontentvar --type HttpContent
defVar --name content2 --type HttpContent
defVar --name content1 --type HttpContent
defVar --name content3 --type HttpContent
defVar --name content4 --type HttpContent
defVar --name success --type Boolean
defVar --name response --type String
createHttpContent --formattype "Json" --contentheader "MyHeader1: test port:8080" --body "{\"tests\":\r\n {\r\n \"test1\":\"First\",\r\n \"test2\":\"Second\"\r\n }\r\n}" content=value
createHttpContent --formattype "Json" --contentheader "MyHeader2: test port:8080" --parameters "test1=First,test2=Second" content1=value
createHttpContent --formattype "Text" --contentheader "MyHeader3: test port:80" --body "<html>\r\n<body>\r\n</body>\r\n</html>" --encoding "Default" --mediatype "application/html" content2=value
createHttpContent --formattype "Xml" --contentheader "MyHeader5: test port:8080" --body "<note>\r\n<from>Anonymous</from>\r\n<to>You</to>\r\n<messsage>We need more coffee users</message>\r\n</note>\r\n" content3=value
createHttpContent --formattype "Xml" --contentheader "MyHeader6: test port:8080" --body "\r\n" --parameters "<from>=Anonymous,<to>=You,<messsage>=We need more coffee users" content4=value
createHttpContent --formattype "Multipart" --boundary asdfasf --contentheader "Warning: test warning" --contentlist "content1=${content},content2=${content1},content3=${content2},content4=${content3},content5=${content4}" multicontentvar=value
httpRequest --verb "Post" --url "https://httpbin.org/post" --formatter "Instance" --source ${multicontentvar} --noproxy success=success response=value
logMessage --message "Sucess: ${success}\r\nResponse: ${response}" --type "Info"
Remarks
HTTP is a protocol that allows you to get resources like HTML documents. It is the basis of any data exchange on the Web and is also a client-server protocol. A complete document is reconstructed from the different subdocuments obtained, for example: text, layout description, images, videos, scripts and more.