It appears that my script is missing my -H option when I am trying to get a response. It is complaining that it is a syntax issue, but it doesn't appear to be. Anyone seen this issue before? I have taken out any identifying info about the API. I have tested this in a terminal, and it returns data correctly
Code:
import org.apache.log4j.Level
import org.apache.log4j.Logger
def log = Logger.getLogger("com.acme.workflows")
log.setLevel(Level.DEBUG)
def headers = "Bearer 12345678-1234-1234-1234-123456789120"
//def response = "curl -H \"Authorization: Bearer 12345678-1234-1234-1234-123456789120\" https://url.com/api/path/end"
def response = 'curl -H \'Authorization: Bearer 12345678-1234-1234-1234-123456789120\' https://url.com/api/path/end'
def proc = response.execute();
proc.waitFor();
log.debug(proc.exitValue())
log.debug(proc.err.text)
log.debug(proc.in.text)
I have also tried without the escapes (\') and with double quotes. It seems like each combination is still throwing errors
Errors:
curl: (6) Could not resolve host: Bearer; Name or service not known
curl: (6) Could not '; Name or service not known
Response:
{"timestamp":1578586566943,"status":401,"error":"Unauthorized","message":"Full authentication is required to access this resource","path":"/api_data/all_data"}
What are you trying to access from the API? Is there a reason you can't leverage the com.atlassian.jira libraries?
I was not aware there were libraries that could handle those calls
I am trying to access a remote DB that stores details information regarding to billing. The return should be a json dump of information.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah gotcha. Didnt realize you were calling out to an external endpoint. In that case a few things to note:
1. The error is saying "could not resolve host" which indicates that it's not catching the parameters as being part of the header arg but instead as the target address. This indicates that the value isnt being recognized as a header value...the quotes arent getting passed through.
Try:
def response = "curl -H 'Authorization: Bearer 12345678-1234-1234-1234-123456789120' https://url.com/api/path/end"
2. Use HttpClient instead for all it's benefits
3. You may have compromised your access token. get a new one before you push this to a production environment ;)
curl: (6) Could not resolve host: d4483b04-e671-4042-94fd-db2027f3a5cd'; Name or service not known
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yikes you are right. It has to be regenerated anyways. I will try your suggestions in the morning, but do you have an example of the httpclient?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.