How to upload application to Cloud Foundry using API (not CLI)? - json

I'm trying to develop a simple NodeJS web app that can more or less replace the Cloud Foundry (CF) CLI. I'm following the API documentation to send the application.zip to the CF Service, however I get an error response Unsupported Media Type.
For the application part of the body I'm sending the application.zip file that is uploaded from the browser.
For the resources part of the body I'm sending an empty Json array. My understanding is that as there is nothing uploaded initially there are no pre-uploaded resources that I want to specify, hence the array is empty.

With the Unsupported Media Type response, I suspect you send invalid request headers to the API. There is a CloudFoundry API client written in node.js and you may read the source code to see how they upload the app code.
If that does not help you, please refine your question and add some code that you have.

Related

API call directly from Design Automation Activity

I am trying to follow DA tutorial to extract data from CAD file and post the data to a web api. Probably I can extract and save a data file in OSS( or somewhere temporarily, I haven't figured out yet), and use my web app to read this file before sending the api request. Instead of this double handling, is it legal to call API directly from Activities? Same like a plug-in in laptop, it programs a local file and then sends a HTTP call.
Thank you.
is it legal to call API directly from Activities? Same like a plug-in in laptop, it programs a local file and then sends a HTTP call.
Currently it is not possible to send Http requests from within Appbundle code, this is something our Engineering team researching.

Link a website (kraken.com) using API on Android Studio

I was wondering how I could link my application to kraken.com server.
For example, making a login activity that sends the username and password to the server and if it's correct, open another activity.
The kraken's API is given by the following link: https://www.kraken.com/help/api
The problem is that I don't know how this API exactly works. How can I make HTTP Request and what is json? Consider I'm new in this area (API).
So firstly, JSON stand for Javascript Object Notation, it's a syntax for exchanging or storing data.
I'm assuming you're using Java since you're using Android Studio.
Looking at Kraken's API page: https://www.kraken.com/help/api#example-api-code
They don't currently have support a 3rd party Java Library for API access. So you would be looking a using a RESTful approach.
Here is an example of how to use that approach in Java: https://www.mkyong.com/webservices/jax-rs/restfull-java-client-with-java-net-url/

Access Google Drive REST without google sdk

I have a lightweight node.js module that needs to pull from google drive. They have a REST/HTTPS interface but AFAICT it's only accessible via their SDK. I want to use REST/HTTPS so I don't have to use an SDK. Is this possible for file download? For file find (file:list e.g. https://developers.google.com/drive/v3/reference/files/list)?
I don't understand why you think it's only accessible using an SDK. The link you posted clearly shows the URL endpoint, lists the optional parameters and gives the format of the JSON response.
If you click "Try it now" and open your browser console, you will see the http request and response which you can mirror in your app.
The only thing you also need to consider is that before making a REST request to Google, you must obtain an Access Token and set it in an Authorization: Bearer xxxxxxxx header, or provide it as a query parameter as &access_token=xxxxxxxxx

Combining Google Cloud Endpoint and Google Cloud Messaging

I have two things. A backend running on App Engine and a Android app. These needs to communicate in a efficient way.
What I already did. I created a api with Google Cloud Endpoints. This endpoint exposes calls. The objects in the backend are mapped to json and mapped back to objects in the Android app. This is what the Endpoints provide.
Sometimes I want to push information from the backend to the Android app. What I do now is I send a Google Cloud Message (GCM) to the Android app and these is updating everything by calling something on the Endpoint of the backend.
This situation is working without problems but it has some drawbacks:
When I update a lot of devices at ones (what is happening a lot in my application) all those devices make a call to the backend and creating a large peak load.
The extra call is using additional battery on the phones.
What I want is to add the updated information into the GCM. GCM has support to add 4kB of data. Large enough to add the json with the updated information. If I want to send more then 4kB I can always use the old situation.
So, basicly what I want is the following:
When I'm going to send a GCM I retrieve the the correct objects from datastore/database.
Those objects needs to be converted to json in the same way as the Endpoint library does.
The json should be added to the GCM.
In the Android application the json should be convert back to objects in the same way as the Endpoint library does.
Continue processing those object the same way as before.
I found a thread that suggested that I should the gson library to do this. But I have problems in both backend and Android app. And also the json itself is not the same. I want to use the Endpoint library to serialize the same json and to deserialize to the same result as a Endpoint call.
Does anybody have any idea how to do that? Maybe a example or tutorial?

Getting a weird error hitting Google Apps Script from Node REST clients

I am setting up a simple Google App Script to get some data from a spreadsheet to an external app. When I open the url from my browser or curl I get the proper JSON response.
See for yourself, here is the url:
https://script.google.com/macros/s/AKfycbwUqrOsqQk4rk0lY97Wl4bRsHVk6_CMVPz3hGHeyc3H2ZCahCIY/exec
You should get a JSON response. I would like to have a node app make a request to that URL and parse the JSON response. I am attempting with two different clients, restler and request, and with both I get this error:
Error: 140735264762208:error:0607907F:digital envelope routines:EVP_PKEY_get1_RSA:expecting an rsa
key:../deps/openssl/openssl/crypto/evp/p_lib.c:288
Any recommendations?
I believe this is a known Node.js issue that there is already a fix in progress for - https://github.com/joyent/node/pull/4827