add http body

Add a message body into an HTTP request.
NameDescriptionTypeModifier
content

Data of the message body.

StringNone
None
This action may be used within the following project items: test modules and user-defined actions.
The following settings are applicable to this action: remove double quotes from cells.

Suppose that you'd like to test a given Google API to send a message to a recipient with the following information:

  • API under test: Users.messages: send.
  • URI: https://www.googleapis.com/gmail/v1/users/me/messages/send
  • Authentication scheme: OAuth 2.0
  • In the request body, supply a Users.messages resource with the following property as the metadata.
    Property nameValueDescription
    rawbytesThe entire email message in base64url encoded string.
    Tip:
    To encode a plain text string into a base64url encoded string, you can use the Online Base64URL encoder tool.
    • Raw body content:
                              
                                  To: [email protected]
      Subject: This is a test mail
      &nbsp
      This is a test mail
                              
                          
    • Base64url encoded body content:
      VG86IGxvZ2lnZWFyZXBndGVzdDJAZ21haWwuY29tClN1YmplY3Q6IFRoaXMgaXMgdGVzdCBtYWlsCgpUaGlzIGlzIGEgdGVzdCBtYWls
    • Request body declared in JSON format {"raw":"base64url encoded string"}
                                
                                    	name	value			
local variable	access token	ya29.Ci-fa76X0cjJXa2Lx0RM-fRyAQ6-6pboEX-iuT7PR-yYv6D-Rfbos7bs151wiL-O7w			
local variable	uri	https://www.googleapis.com/gmail/v1/users/[email protected]/messages/send			
local variable	encoded body content	VG86IGxvZ2lnZWFyZXBndGVzdDJAZ21haWwuY29tClN1YmplY3Q6IFRoaXMgaXMgdGVzdCBtYWlsCgpUaGlzIGlzIGEgdGVzdCBtYWls			
&nbsp					
create http request					
&nbsp					
	schema	value			
authenticate	oauth 2	# access token			
&nbsp					
	key	value			
add http header	Content-type	application/json			
&nbsp					
	content				
add http body	# "{""raw"":""" & encoded body content & """}"				
&nbsp					
	uri	method	timeout	variable	expected code
send http request	# uri	POST	200	>>response	200
&nbsp					
	response	status	header	body	
parse http response	# response	>>status	>>header	>>body	
                                
                            
  • An HTTP request must be instantiated via create http request before calling this built-in action.
  • Properties of the request body must be written in JSON format.
  • This action supports the <ignore> modifier. If the string <ignore> is present as the value of the argument, or the argument contains an expression that evaluates to <ignore>, the action is skipped during execution.

Copyright © 2024 LogiGear Corporation. All rights reserved. LogiGear is a registered trademark, and Action Based Testing and TestArchitect are trademarks of LogiGear Corporation. All other trademarks contained herein are the property of their respective owners.

LogiGear Corporation

1730 S. Amphlett Blvd. Suite 200, San Mateo, CA 94402

Tel: +1 (650) 572-1400