How can I, using the Cast SDK or otherwise, have my app trigger a Chromecast reboot, in the manner of the official Chromecast app?
In the case of 'otherwise', is Google Play likely to look unkindly on this approach?
There is no API in the SDK to reboot a Cast device and frankly, it is scary to me that you would want to do that programmatically. What is the reason you would want to do that?
You definitely should be able to. It's just a HTTP post after all. This from pychromecast
CC_SESSION.post(FORMAT_BASE_URL.format(host) + "/setup/reboot", data='{"params":"now"}', timeout=10)
That might point you in the right direction.
Following on the answer from davewasthere (thanks!), I found that I can reboot a Chromecast by performing the following command from Linux prompt:
curl -Lv -H Content-Type:application/json \
--data-raw '{"params":"now"}' \
http://10.10.2.49:8008/setup/reboot
Some other useful DIAL commands
A recent firmware update seems to have disabled the HTTP endpoint on port 8008 (HTTP/1.1 403 Forbidden) so the solution posted by norganna does not work any longer.
Working alternative is the HTTPS endpoint on port 8443:
curl -Lv --insecure -H Content-Type:application/json --data-raw '{"params":"now"}' https://10.10.2.49:8443/setup/reboot
Related
I am getting a 403 response from the Power BI rest API and I am not sure why.
Here is the request I am making in cURL format(my actual web app is in Java):
curl -X GET -H "Authorization: Bearer accessToken" -H "Cache-Control: no-cache" 'https://api.powerbi.com/beta/myorg/dashboards'
I have given all Power BI Service permissions on my app in the azure management portal.
Do I need to replace 'myorg' with an actual org name? If so where would I find my org name? What am I doing wrong? This request seems to work for me in Aipary.io so I think it has something to do with my app not the request.
I have tried this request with both an admin account and a regular user and I get 403 responses for both of them.
I have also tried removing the Power BI Service permissions from the app with my admin account and then adding them again. That didn't work.
It seems to be that the 403 response was caused by the request in cURL missing some required parameters. The 403 response should show the error information that might be ignore.
Per my experience, I recommand you can try to use the GUI tool Postman in Chrome for requesting the APIs like cURL.
For checking the issue, you can follow the toturial https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-authenticate-a-web-app/ to make sure the request required parameters correct.
However, according to your description for the issue, I can't locate the problem whether the prepare steps cause. So I suggest you can try to review the complete toturial https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-steps-to-create-a-power-bi-app/ to be sure the every step is correct.
Hope it helps. Any concern, please feel free to let me know.
How to use the cURl command
curl https://na1.salesforce.com/services/data/v20.0/query?q=SELECT+name+from+Account
-H "Authorization: Bearer access_token" -H "X-PrettyPrint:1"
in java to call sales force rest web services
Java has an URLConnection Class that has similar functions as cURL.
For interacting with the salesforce API, it is best to use a client library and not implement it all by yourself, see http://blog.palominolabs.com/2011/03/03/a-new-java-salesforce-api-library/ for an example.
Easiest way is to download cURL java wrapper like https://github.com/pjlegato/curl-java and use cURL directly in your code.
Second way is to use Runtime.getRuntime().exec("crul...") "pattern" and run curl as a normal process.
I'm really new to APIs and POST or PUT or DELETE. I'm also new to running APIs using POST or other.
I have given a document which says
Function :- Add new Item
URI :- qtp/qtps
ACTION :- POST
REQUEST :- <n1:qtp xmlns:n1="http://www.mac.com/qts/xml/ns/qtm/qtpManagement"><name>rosa qtp 3</name><ipAddress>171.68.121.232</ipAddress><macAddress>10:0t:24:03:r7:57</macAddress><description>this is rosa qtp </description></n1:qtp>
I have absolutely no idea how to proceed further, But I know that by executing the request I need to Add a new Item in the application server, I tried something with browser myself but it did not work.
Can someone show me how can I work with this or explain me more about this or at-least give me a clue
One of the most useful tools for testing and debugging HTTP requests, in my experience, is cURL (http://curl.haxx.se/).
cURL is actually the under-the-hood library used for HTTP requests by a majority of PHP apps; the command-line version lets you do virtually anything that HTTP can do, and get great debugging data.
In the scenario you describe above, after downloading and installing cURL you'd likely use a command like:
curl --header "Content-Type: application/xml" --data '<XML YOU WANT TO SEND>' -X POST <URL TO WHICH DATA SHOULD BE SENT>
It's not clear from your question what the destination host+url is, but using the specific sample data you provide this would probably look like:
curl --header "Content-Type: application/xml" --data '<n1:qtp xmlns:n1="http://www.mac.com/qts/xml/ns/qtm/qtpManagement"><name>rosa qtp 3</name><ipAddress>171.68.121.232</ipAddress><macAddress>10:0t:24:03:r7:57</macAddress><description>this is rosa qtp </description></n1:qtp>' -X POST http://www.mac.com/qtp/qtps
Install a firebug plugin for that. You can use SOA client.
This is the second part of my question on converting cURL to Java
The first part is titled:
Converting cURL authentication to Java and retrieving & updating data using REST XML (Pt.1)
Third, how can I implement update, create, and delete for the api in Java? For example:
Update: curl -i -X PUT -H "Content-Type:application/xml" -H "Accept: application/xml" -d "<ticket><description>Take this description</description></ticket>" http://user:password#www.assembla.com/spaces/my_space_id/tickets/1
Delete" curl -i -X DELETE -H "Accept: application/xml" http://user:password#www.assembla.com/spaces/my_space_id/tickets/1
Create: curl -i -X POST -H "Content-Type:application/xml" -H "Accept: application/xml" -d "<ticket><summary>This is a Summary</summary><priority>3</priority></ticket>" the weblink
In other words, how can I convert these cURL code into Java?
I would really appreciate your help. Also, a good reference to do such stuff in Java will be awesome too.
Thanks.
Well, the official API usually helps: Assembla REST API
There is says that you need to use basic authentication.
For accessing REST in Java: Rest clients for Java?
you should be looking out for Apache HttpClient tutorials.
There's some Samplecode of a Android Rest Client application around, try searching for it. Also, I just discovered "resting". I haven't tried it, but might be worth a look.
Also watching the Developing Android REST client applications video from Google.io is recommended, as it is teaching some very important architectural basics and hints.
I placed a similar question some time ago, and got an answer here at Stackoverflow.
I want to make a multi-user client-server solution with Java Swing thick client as a front-end and Google AppEngine (Java one) as a back-end.
The problem is that GAE provides only web-based forms for logging in and out, so there's no trivial way to employ Google Accounts features in a thick client.
Can you give some advices/hints/ideas on how to allow a thick client login to and logout from a GAE webapp?
There is a way for client apps to authenticate against Google Accounts, but I don't know if the token you receive can be passed back to AppEngine. See: ClientLogin for Installed Applications
I am sorry, I can only answer you indirectly. It is possible to log in to an app on appspot.com with a Google account. You just have to do everything a browser would, including keeping some cookies and contacting several servers as they bounce you around.
I played around with this for a stillborn project a couple of months ago and ended up with a shell script that mostly runs cURL to log in. Perhaps you could take from it what you need.
#!/bin/bash
my_app="set-this-to-my-app-id"
url="http://$my_app.appspot.com"
curl='curl --cookie-jar cookies'
if [ -z "$EMAIL" -o -z "$PASS" ]; then
echo -n 'Email: '
read EMAIL
echo -n 'Pass: '
read PASS
fi
rm -f cookies auth
echo 'Login'
$curl https://www.google.com/accounts/ClientLogin --output auth \
-d "Email=$EMAIL" -d "Passwd=$PASS" \
-d accountType=HOSTED_OR_GOOGLE \
-d source=$my_app \
-d service=ah
. auth # XXX Be careful here. The output of the above
# command happens to be Bash syntax too!
rm -f auth
echo 'Logging into app and getting cookie'
$curl "$url/_ah/login?continue=$url/console/&auth=$Auth"
echo
echo 'Example POST query'
$curl -X POST --cookie cookies "$url/some/path" -d 'foo=bar'
echo
rm -f cookies
as suggested by #Jason DeFontes the ClientLogin authorization process is addressing this issue.
as a minimal-effort alternative approach, you could embed the web-based (html) forms into your thick client, i.e. use a java component that supports html-rendering (like a JEditorPane with an HTMLEditorKit installed) and present this component inside your swing app -- at least users would not need to switch back-and-forth between your app and the browser this way.