Sending a URL/filePath in Resteasy request - rest

I want to send path of a file alongwith some Strings.
After spending some time I was unable to find anything that can help. Could anyone suggest any link on how to do this on server side

You can use any of the following methods to submit a file path and some strings to the server:
Submit a Form with the file path and strings.
Encode the file path and send it as a query parameter in the URL along with the strings.
Create a message body containing the file path and other strings you want to send and submit it via a POST call.
Send the file path and strings in custom http headers.
Take a look at the Resteasy documentation here: http://docs.jboss.org/resteasy/docs/3.0.4.Final/userguide/html_single/
Pay special attention to the sections that talk about using the #Form, #FormParam, #QueryParam, and #POST annotations.

Related

Restygwt download byte[]

I have only an array of byte on the client side.
Another server send me JSON
{
report - byte[]
}
I am looking for ways to save byte [] in browser
Send them to server or I can download from client side.
I can not find any solution at all.
So my question "Is it possible to save with restygwt byte [] an how???"
It is not possible to save the file directly from Resty.
https://github.com/resty-gwt/resty-gwt/issues/341
The most common workarounds to download files using AJAX are not using AJAX at all.
You can simply change the URL (using window.location) or (using javascript) create or;
create a form (using JS) and post that form.
In my projects, I simple create a URL to my REST endpoint attaching any query parameters needed and use it as the href to a link.
For instance, if your RestyGwt endpoint points to /entity/1/bytes
just do
new Anchor("Download", "/entity/1/bytes");
your endpoint must produce a downloadable file type say:
#Produces("text/txt")

Cloudinary Error: "Missing required parameter - file" via REST API

I'm just getting started with Cloudinary, and I'm attempting to Uploading with a direct call to the API. Using the DHC REST Client (chrome extension), I put my request together per the instructions found here at Creating API authentication signatures. Here's a screenshot of that request and response.
I also tried...
adding quotes around all values except timestamp as shown in the example
making the request a multi-part request and attaching the image to the body as a "file"
deleting timestamp, api_key, and signature and instead replacing them with upload_preset to try and upload an unsigned image (yes, I created the preset)
And finally, I did try adding public_id even though it says it would assign one if not provided.
In all cases, I get the same error response... Missing required parameter - file
Can anyone tell me what I'm missing?
Ok, figured it out. These name/value pairs need to be added to the body of the request rather than the header. Here's what that would look like in the DHC client. Note that the upload_preset will not work for you... I only created it to test with. Also note that doing a signed request is accomplished the same way but with different parameters.

Get non file body from multipart/form-data using AWS API Gateway and Lambda

I am trying to get the form data from a multipart/form-data POST to my ASW Lambda web service via API Gateway.
The HTTP POST has Content-Type "multipart/form-data" and body that is URL encoded. File data is also sent in this post (hence the multipart, I guess).
The web service needs to integrate with a thirdparty service, so changing the format of the POST isn't really an option.
I have seen this thread talking about converting the URL encoded data to JSON object for use in Lambda, but this doesn't do the trick.
I have also tried setting the Integration Request -> Mapping Templates for content type multipart/form-data to Input passthrough. This didn't help either.
I did come across another question about uploading a file using multipart/form-data, but since I'm not interested in the file, just the body, that answer didn't help.
Below find screenshot (sorry) of the captured post via runscope.
If the goal is to use Lambda, you'll need to pass valid JSON to the function. Currently there isn't a way to JSON-ify data inside Api Gateway that comes in as non-JSON data.
Our short term fix (on our backlog) is to provide a variable in the mapping templates to grab the raw input of the request. That way you could do a simple JSON conversion using a template like:
{
"body" : "$input.body"
}
or something like that.
Check out the mapping template reference for more info: http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
Edit 4/7 - feature has been released as $input.body

Is it possible to change/modify properties of a CR using OSLC_CM?

Is it possible to modify a property of a change request by using the OSLC-CM REST API of a change management system. The system that I'm trying to achieve that is Rational Change.
I can browse and query via the REST API, but to modify anything I need to resort to command line which is rather slow.
Is there a way?
BR,
Pawel
To update resources using the OSLC-CM REST API you simply just can use HTTP PUT. In order to do this, you'll first need the URL of the Change Request.
The steps to achieve this (using any HTTP client) are:
acquire URL for Change Request (usually done by query, or stored reference, etc)
Perform an HTTP GET on that URL, specifying a format for use in editing. This is done using 'Accept' header, some typical values would be 'application/xml', 'application/json' or 'application/rdf+xml'.
Note, it is a good idea to set the header 'OSLC-Core-Verson: 2.0' as well to ensure you are working with the 2.0 formats.
Once you have fetched the resource, modify the property to the value you want.
Using HTTP PUT, send the modified resource in the content body to the same URL you fetched the resource from.
Additionally you will most likely need to pass along some additional headers to help the server detect any possible conflict.
You should get back a 200 (OK) or 204 (No content) response on success.
An optimization would be to do the same steps as above but only request the properties of interest and only send them by using the selective properties feature of OSLC.
So I've finally got it working with some help from googlegroups
To recap what I've done so that someone else might benefit too (I really have searched for it and the IBM documentation is as in most of the cases not helping):
So to modify PR/CR' implement_actual_effort attribute on the Rational Change server the following procedure was successful (using Firefox REST plugin):
1. In Headers set: Accept to application/xml, Content-Type to application/xml
Put the oslc address of the cr i URL in my case it was:
http://[IP:PORT]/change/oslc/db/[DB hex ID]/role/User/cr/[web_encoded_name_of_the_CR]?oslc_cm.properties=change:implement_actual_effort
(note in browser http://[IP:PORT]/change/oslc/db/[DB hex ID]/role/User/cr/[web_encoded_name_of_the_CR] will open change page of the CR/PR)
In REST client set Method to GET and press SEND
Click on the Response Body (RAW), copy xml Body
Change Method to PUT, change the value of the attribute (in the xml in Body window)
Press SEND
Attribute should have been changed right now, and the response should be similiar to what you've sent, with the attribute showing the change.
Note that to change an attribute (called property from oslc point of view) one has to provide ?oslc_cm.properties=[properties delimited with comma]
and in the request body xml the same properties have to be present, if I remember correctly if the property isn't mentioned in the xml it will be set to default
I hope this helps someone
BR,
Pawel

soapUI: multipart/form-data REST request with file attachments

I am using soapUI for testing a REST web service. Is there a way to attach a file with the other parameters in a multipart request? I see the attachment tab in the panel but I cannot give that attachment a parameter name so that server can identify. It's not helping.
I found it but forgot to post it here. It was not so intuitive.
In your REST Request if you can see an attachment tab, open it and add and attachment with + button. The Name of that file would show full path. e.g. C:\temp\my-file.csv
In you parameters tab, add a parameter and give it a name. The value of that parameter will be file:C:\temp\my-file.csv
In SoapUI 5.x and greater, you must select the "Post QueryString" checkbox. Without this, the file will not be send along with the request.
That should be it. When attaching a file if you select Yes when it asks to Cache the file, you won't have to specify full path in step 2 above. The value of file parameter should be file:my-file.csv
select mediatype as application/json and then add the json string to that. It will go to server as payload. Usually this request is of POST or PUT type