- authentification Basic
- connexion sécurisé over SSL
- utilisation du charset UTF8
Maintenant place au code :
import groovyx.net.http.*
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.1' )
def urlStr = "https://blabla.com"
def content = '{"key":"value"}'
def login = "myLogin"
def password = "myPassword"
def http = new RESTClient(urlStr)
http.encoderRegistry = new EncoderRegistry(charset: "utf-8")
http.auth.basic login, password
def response = http.put(requestContentType: ContentType.JSON, body: content)
if (response.status != 204) {
log.warn("Operation failed: " + response.status + ", on url " + urlStr + ", with content : " + response.data);
}
Aucun commentaire:
Enregistrer un commentaire