Heroku application log streaming - api

I'm trying to use the new Heroku api to stream the logs of my application using curl:
Here is what is said in the doc (https://devcenter.heroku.com/articles/platform-api-reference#app)
Streaming is performed by doing an HTTP GET method on the provided logplex url and retrieving log lines utilizing chunked encoding.
So first I retrieve the logplex url:
curl -X POST https://api.heroku.com/apps/my-app/log-sessions \
-H "Accept: application/vnd.heroku+json; version=3" \
-H "Authorization:XXX" -v
Then I get something like this in the response:
"logplex_url":"https://logplex.heroku.com/sessions/abcdef-079b-4264-a83c-031feb31bfc2?srv=132456798"
So I make another curl call:
curl -X GET "https://logplex.heroku.com/sessions/abcdef-8a7e-442f-a164-4c64e845b62d?srv=123456798" -H "Transfer-Encoding: chunked"
I got a persistent connection but nothing comes...
If I don't specify the Transfer-Encoding header, I get the logs, but the connection close.
Is it really possible to stream the logs, like it's specified in the reference ?

It is possible, unfortunately I was mistaken in writing it and it is not chunked encoding as I believed. We do use this interface in the CLI and in log2viz, but it is unfortunately not standard http per se.
Basically you should do a normal HTTP request and read back the HTTP response headers. Given the headers returned you would then normally read from the socket until you got a zero length read, at which point you can assume you are done and finish up. In the logplex case we are reticent to block (perhaps indefinitely) so we go ahead and return an empty read. Then we just expect that when you are done you can simply close the socket.
Unfortunately I was unable to figure out how to do this with cURL. But I can point to the examples in our open source where we tackle this, and hopefully that will help.
toolbelt - https://github.com/heroku/heroku/blob/master/lib/heroku/client.rb#L482
log2viz - https://github.com/heroku/log2viz/blob/master/app.rb#L153
Hopefully that helps clarify the current situation at least, I'll try to update the docs to reflect this. Thanks for the detailed report and let me know if you have additional questions I can help with.

Related

500 - Internal Server Error during Spotify's Client Credentials Authentication flow

I'm attempting to authenticate my application using Spotify's web API Client Credentials Authorization flow, but despite the seemingly simple task, every response I've gotten has returned a 500 - Internal Server Error.
I've attempted many times in both cURL and within my application (Android) to no avail. Following the guides here: https://developer.spotify.com/web-api/authorization-guide/#client_credentials_flow
I've set up my cURL as such
curl -XPOST -H 'Authorization: Basic ODZiMDJ...MWI=' -d 'grant_type=client_credentials' 'https://accounts.spotify.com/api/token'
The request is structured with identical headers, body, and URL in the code as well, but I have yet to receive any valid responses.
Another question posted here gives a seemingly identical request, aside from the optional "Scope" parameter.
My apologies if this seems like a vague question - I'm not sure what else to try, but I'd be more than happy to provide any additional details. Any help is appreciated.
code and redirect_uri body parameters are required according to documentation

Confluence REST API Authorization Failure

I am trying to use the Confluence REST API to create a page. I am using the curl example off of the documentation found HERE. Every time I try to run a terminal command using this curl I get a response that says 'HTTP Status 401 - Basic Authentication Failure - Reason : AUTHENTICATION_DENIED'. I see that someone else had a similar issue regarding their C# code, but there was never a resolution given. Hopefully someone with experience will be able to tell me what I am doing wrong. My curl is listed below with the sensitive parts replaced in <> format.
curl -u <USER>:<PASSWORD> -X POST -H 'Content-Type: application/json' -d'{"type":"page","title":"new page","space":{"key":"<PAGEKEY>"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' https://<SERVER>/wiki/confluence/rest/api/content/ | python -mjson.tool
I was finally able to resolve this. Through a combination of the answer here How to create new page in Confluence using their REST API? and using a login that had the appropriate permissions.

Wirecloud / Fi-Ware edit request header in http.makerequest method

I’m working on an widget for the fiware mashup. It needs to get data in json from a server. I’ve realized that with the MashupPlatform.http.makeRequest.
The problem is, the server sends xml back, if I don’t ask to get json. I don’t find any option in the widget api to to do it so. (like the curl option --header 'Accept: application/json')
As you have said, when you perform an HTTP request, you should add the Accept header to specify the response format. When you are using the MashUp Platform to make requests, you can specify the headers by adding the object "requestHeaders" in the options parameter. For example:
MashupPlatform.http.makeRequest("http://YOUR_SERVICE_URL/PATH", { "requestHeaders": {"Accept":"application/json"}});
You can check all the options that you can include in a HTTP request in the documentation: https://wirecloud.readthedocs.org/en/latest/widgetapi/widgetapi/#request-options-general-options
Best Regards

API Post Data to Middleware

Anyone know how I can test posting data to this url? I was given the link by the IT supervisor and trying to have the data posted to the following link by submitting the following form. He said it would accept anything I send it
Could could do this via curl:
curl -X POST -d "data=anything_i_send_it" http://powersource.braindongle.com/lead-manager/lead/new/omgpost/sessions/
Or using another HTTP tool like Hurl.it
Or using a Chrome extension like Postman or REST Console.
Advanced Rest Client is an easy way to do it. It's a free chrome extension that can form http requests with data.

Create an ajax call

i've never used an ajax call,can anybody suggest me to create a jquery ajax call using this api (parse.com),what is H,G?:
curl -X GET \
-H "X-Parse-Application-Id: qS0KLMx5h9lFLGJIpj9qyhM9EEPiTS3VMk" \
-H "X-Parse-REST-API-Key: nh3eoUo9GF2gMhcKJIfIt1Gm" \
-G \
--data-urlencode 'username=cooldude6' \
--data-urlencode 'password=p_n7!-e8' \
https://api.parse.com/1/login
curl is a tool for sending HTTP requests. The -H flag sets a header and -G specifies that the data should be transmitted as a URL query parameter rather than content body. In this case, your command sends an HTTP GET command with the custom headers "X-Parse-Application-Id" and "X-Parse-REST-API-Key". This request was sent to https://api.parse.com/1/login?username=cooldude6&password=p_n7!-e8.
You don't need to become a CURL expert to use Parse; the REST API helps you understand how the Parse API works across the wire, but there are both first and third party APIs for just about every language you would need.
P.S. The Parse docs page helps you by pre-filling the value of X-Parse-Application-Id and X-Parse-REST-API-Key with keys from your actual app. By posting these keys online, others can write code that will look like your app to Parse. Though best practices would suggest you secure your app so that it's OK for these keys to leak (e.g. by setting class-level permissions), you may consider deleting & recreating a new app since it sounds like you are just starting development.