Query REST API with image data using CURL - image

I have a RESTful API (built on flask) which has to return JSON after receiving an Image file. So this has to be done through GET request with image data. SO, how do i use CURL to query the REST API on image data through GET request? Which format will it be sent to the server for me to retrieve it?

Related

Unable to get data from bulk API call

I am trying to load data in FHIRBASE through a bulk API call.I have used the below command for the same:
fhirbase --host localhost -p 5432 -d fhirbase -U postgres -W postgres --fhir=3.3.0 load -m insert http://localhost:6544/patients
This endpoint 'http://localhost:6544/patients' has json data.
Getting a response:-No Content-Location header was returned by Bulk Data API server.
Thanks for your interest in Fhirbase!
Bulk Data API is not a part of FHIR specification yet. However, there is a draft specification in the working group's GitHub repo: https://github.com/smart-on-fhir/fhir-bulk-data-docs/blob/master/export.md. This page fully describes Bulk Data API requests and responses.
Bulk Data API works asynchronously, which means that a client does not receive the response immediately, as with regular REST endpoints. Instead of that, client initiates (kick-offs) a Bulk Data API request describing data he's interested in. Server responds with 202 Accepted and returns temporary URL in Content-Location header. Client will poll this URL to know if bulk data files are ready or not.
In your case, Fhirbase complains that your Bulk Data endpoint does not return that temporary URL to get current request's status. Without that URL Fhirbase cannot proceed to actual NDJSON files download.

Upload image to Lambda using gateway API

I'm trying to let user upload pictures to a lambda function for processing; using the gateway API interface.
I tried to specify a model for my POST method, but so far I keep getting the error
Invalid model specified: Validation Result: warnings : [], errors : [Invalid model schema specified]
... Not so helpful.
I understand that I cannot directly send raw data to lambda and must using some kind of formatting in-between.
What I understood is that I could make the gateway interface base64 encode the data for me.
I tried to do so by using the following model schema with the content type image/jpeg
{
"body" : $util.base64Encode($input.body)
}
How to send the image ?
There is no native support in API Gateway for binary data as you have seen. We are working on this but I don't have an ETA for you. Some customers have had success base64 encoding the data like you have in your question, only it should be in a mapping template in the Integration Request not the Method Request.
If you set the content type to image/jpeg, then the encoding will apply only when the Content-Type header on the incoming request is also image/jpeg, so make sure to set that.
You can also reject incoming requests to the method that don't send the right Content Type by setting the 'Request body passthrough' (passthroughBehavior in the API) to the recommended value ("when there are no templates defined" or 'WHEN_NO_TEMPLATES' in the API)
Docs for the passthrough behavior -> https://docs.aws.amazon.com/apigateway/api-reference/resource/integration/#passthroughBehavior
Since it seems like working with binary data and API Gateway is complicated, I think you should:
Upload the image using API Gateway as an S3 proxy
Set a trigger for your lambda function on PUT for the bucket where you've uploaded the image

Access data using ajax in json format from proxy url in shopify

I developed an app and defined a proxy url. I want to get the data from that url in json format in my shopify shop.But it is returning me nothing. If I read in html, It shows me data. Please tell where I am going wrong?

Retrieve JSON response when creating video on Brightcove

I followed the example on http://docs.brightcove.com/en/video-cloud/media/references/reference.html#Video. The response gets shown in an iframe. However, I would like to be able to get the JSON response in order to store the data (i.e., Brightcove video ID) in my own database. I tried using AJAX post but Brightcove doesn't seem to accept post requests from a different origin. Is there a way to simply get the response data without displaying it in an iframe or in a separate window?
You can't get the response data in javascript since the API response does not include CORS headers. You'd need to do this in server-side code, which also has the advantage of not exposing your API token to the browser.

Receive JSON format through REST api without using REST Client

IN magento, as I am using REST api to get the product details with url like http://myserver.com/magento/api/rest/products? But this url returns only in XML format. But I need it in the JSON format.
Can anyone suggest me how to get it in JSON format without using REST client??
you need to set request header explicitly to application/json then the response is served in json.

Resources