a call to query consoleText returns with HttpStatus 100 - how to deal with that? - rest

I am working on a program than launches Jenkins jobs using the REST API. After the job has completed, I'd like to get its log, so I call http://jenkins.domain.com/job/my_job_name/#/consoleText in my code.
In 75% of the cases that works and I get the text in return. But there a some cases where it comes back with HttpStatus 100 and no text. (Opening the URL with the browser then shows the text, so clearly there is something to return.) (I haven't found any pattern that would explain it, like "exceptionally large log" or so.)
I found no documentation about calls returning 100 and have no idea how to proceed. Simple repeating the call gives the same result. So how can I get the expected result?

Surprisingly "exceptionally large" was the answer. This caused a timeout (followed by some inappropriate handling) in the library that I used to handle the HttpGet. (Fortunately it was fixed very quickly.)

Related

I need simple proxy between 2 rest APIs

My code is working ok for GET/POST/PUT to/from restApi1 and restApi2.
However, my problem I need to implement HEAD/OPTIONS (no body!) and GET uri1
HEAD/OPTIONS could return 204 or 200 depends on a process status. I am getting error "Stream closed". Sounds like Camel want body bytes, but I don't indend to have it. Even I set ExchangePattern.InOnly or optional etc error occur...
What is correct way to see responses and handle requests WITHOUT body, just statuses exchange?
How to see response from restApi2 on Camel rest("/restApi1").head().route().routeId("id1")
.to("direct:restApi2").routeId("/id1").setHeader(Exchange.HTTP_METHOD,constant("HEAD"))
setExchanggePattern(ExchangePattern.OutOptionalIn).recepientList(simple(restApi2));
I figured it out. Need to set '.convertBodyTo(String.class)' even I don't have a body.

403 - Insufficient Permission only on accountSummaries call

I'm getting rejected only on the accountSummaries/list management call, everything else works fine - heck, it works even when executing it from the reference page! I double checked that the account being used was correct and, as I said, I have no issues performing the simple accounts/list call.
I'm using the python library, and for both of those calls no parameters are needed (so the chance of some embarrassing error are very low).
Basically I'm simply getting the service client and performing the simplest possible call:
a = client.AnalyticsManagementClient() # super simple wrapper
a._service.management().accounts().list().execute()
a._service.management().accountSummaries().list().execute()
The first call works fine, the second one returns a 403 error. Anyone have an idea why that might happen?
Full error is HttpError: <HttpError 403 when requesting https://www.googleapis.com/analytics/v3/management/accountSummaries?alt=json returned "Insufficient Permission">
It was just a scope issue: accounts needs at least one among
https://www.googleapis.com/auth/analytics
https://www.googleapis.com/auth/analytics.edit
https://www.googleapis.com/auth/analytics.readonly
while accountSummaries allows only the last two; it seems to be the only one that does not work with the analytics scope, which is the one our client was requesting.

GoodData Export Reports API Call results in incomplete file

I've developed a method that does the following steps, in this order:
1) Get a report's metadata via /gdc/md//obj/
2) From that, get the report definition and use that as payload for a call to /gdc/xtab2/executor3
3) Use the result from that call as payload for a call to /gdc/exporter/executor
4) Perform a GET on the returned URI to download the generated CSV
So this all works fine, but the problem is that I often get back a blank CSV or an incomplete CSV. My workaround has been to put a sleep() in between getting the URI back and actually calling a GET on the URI. However, as our data grows, I have to keep increasing the delay on this, and even then it is no guarantee that I got complete data. Is there a way to make sure that the report has finished exporting data to the file before calling the URI?
The problem is that export runs as asynchronous task - result on the URL returned in payload of POST to /gdc/exporter/executor (in form of /gdc/exporter/result/{project-id}/{result-id}) is available after exporter task finishes its job.
If the task has not been done yet, GET to /gdc/exporter/result/{project-id}/{result-id} should return status code 202 which means "we are still exporting, please wait".
So you should periodically poll on the result URL until it returns status 200 which will contain a payload (or 40x/50x if something wrong happened).

FiddlerScript throws NullReferenceException on headers.ExistsAndContains

This is driving me nuts and it may be something simple, but every time I call the following from Fiddler script is throws a NullReferenceException:
if (oSession.oResponse.headers.ExistsAndContains("Content-Type", "html")){...
This is straight off the Fiddler script knowledge base and I've got the same thing happening on two different Win 8 machines. It seems that oSession.oResponse.headers is null and yes, I am calling this from within OnBeforeRequest!
Same deal with oSession.responseBodyBytes - it looks like the response is null inside OnBeforeRequest. Otherwise Fiddler is behaving normally, traffic proxies through just fine and everything else looks good.
Ideas?
The oResponse.headers and oSession.responseBodyBytes objects don't exist until after the request has been sent to the server and the response has been read back. If you want to interact with the Response headers and body, do so inside the OnBeforeResponse function instead.
The KB was mangled a bit when updated for the new site. I'll file a bug to have this made more explicit.

fields parameter not working with graph batch requests

I have moved my graph requests to a batch, and noticed that when more than one request parameter is passed, the request fails with error 400.
For example, this works when not batched:
facebook->api('/me/friends?limit=5000&fields=id')
But when the same graph url is moved to a batch request, I get a 400 error.
When I remove one of the parameters (either fields or limit), it works:
/me/friends?fields=id
/me/friends?limit=10
Anyone knows if this is a bug or should be like this for some reason?
Finally found the answer to my problem. It appears that the & char must be escaped with %26 in order for this to work.
So my code sample should be:
facebook->api('/me/friends?limit=5000%26fields=id')
Wish this was documented...