Last active
January 17, 2020 09:54
-
-
Save ldclakmal/4536607552d271b7d4fe53828e73ac77 to your computer and use it in GitHub Desktop.
Ballerina HTTP/2 client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ballerina/http; | |
import ballerina/log; | |
http:Client clientEP = new("http://localhost:9095", config = { httpVersion: "2.0" }); | |
public function main() { | |
var responseVar = clientEP->post("/hello/sayHello", "Hello Ballerina!"); | |
if (responseVar is http:Response) { | |
var payload = responseVar.getTextPayload(); | |
if (payload is string) { | |
log:printInfo(payload); | |
} else { | |
log:printError("Error while reading payload.", payload); | |
} | |
} else { | |
log:printError("Error while sending POST request.", responseVar); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment