Migrating a sequence of curl commands into the REST plugin

Say that you have an existing snippet that you tested in curl like:

to make that work with the rest plugin, choose the operation that matches the HTTP method that you used with curl.

copy the URL. You can use groovy to convert https://bitbucket.com/projects/DEV/repos/ebs/pull-requests/72/mere?version=0

to “https://bitbucket.com/projects/DEV/repos/ebs/pull-requests/” + PR_ID + “/mere?version=0

Now you can pass the pull request ID into the operation.

The headers come from -H (--header) and go into the headers box.

Three double quotes will allow for multiline strings in groovy.

image-20240325-191753.png
"Authorization=Bearer " + SECURE_TOKEN_PROPERTY + """ Accept=application/json Content-Type=application/json"""

The -d (--data) goes to the body. If you used a body path, it goes there instead.

Fill in the body media type appropriately (if post/put/patch)

The response is available to the workflow at the bottom.

Create workflow variables and reference them here. In this case, we made and used workflow variables ResponseCode and ResponseString.

If you are expecting to receive json or xml back, you may want to parse it and make decisions on it.

If so, use the parseJson or parseXml operations to do so.

Again, you would want to create a workflow variable to get the data from the operation that you are on into the workflow, and then use it in the next.

The following macros are not currently supported in the footer:
  • style