Created
May 10, 2021 18:20
-
-
Save nafeger/34daeeed2f6c9b9f5456de1c4de77069 to your computer and use it in GitHub Desktop.
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 groovy.json.JsonBuilder | |
import org.apache.log4j.Logger | |
import org.apache.log4j.Level | |
import groovyx.net.http.* | |
def key = issue.key | |
def customFields = get("/rest/api/2/field") | |
.asObject(List) | |
.body | |
.findAll { (it as Map).custom } as List<Map> | |
def customFieldId = customFields.find { it.name == 'Custom Field Name' }?.id | |
def customFieldValue = issue.fields[customFieldId] as String | |
logger.error("key: "+key) | |
def at_base_key = "XXXX" | |
def at_table_name = "XXXX" | |
def at_token = "Bearer XXX" | |
def response = Unirest.post("https://api.airtable.com/v0/${at_base_key}/${at_table_name}") | |
.header("accept","application/json") | |
.header("Content-Type", "application/json") | |
.header("Authorization", at_token) | |
.body("""{ | |
"records": [ | |
{ | |
"fields": { | |
"Key" : "${key}", | |
"Custom Value": "${customFieldValue}" | |
} | |
} | |
] | |
}""") | |
.asJson() as HttpResponse<JsonNode>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment