Chilkat2-Python
Chilkat2-Python
Send a Bodyless REST Request into a StringBuilder
See more REST Examples
Demonstrates Rest.FullRequestNoBodySb, which sends a request with no body and stores the text response body in a StringBuilder.
Background. This variant of the no-body full request writes the response into a StringBuilder rather than returning it as a string, which is convenient when the response will be further processed in place.
Chilkat Chilkat2-Python Downloads
import sys
import chilkat2
success = False
rest = chilkat2.Rest()
bTls = True
bAutoReconnect = True
success = rest.Connect("example.com",443,bTls,bAutoReconnect)
if (success == False):
print(rest.LastErrorText)
sys.exit()
# FullRequestNoBodySb sends a request with no body and stores the text response body in a
# StringBuilder.
sbResponse = chilkat2.StringBuilder()
success = rest.FullRequestNoBodySb("GET","/api/items/123",sbResponse)
if (success == False):
print(rest.LastErrorText)
sys.exit()
responseText = sbResponse.GetAsString()
if (sbResponse.LastMethodSuccess == False):
print(sbResponse.LastErrorText)
sys.exit()
print(responseText)