Expected json response by JQuery File Upload Basic plus UI when delete fails - jquery-file-upload

When using the JQuery File Upload UI plugin, https://github.com/blueimp/jQuery-File-Upload, what is the expected json response when the delete button is clicked for an uploaded file and an error occurs during the delete on the server or the delete process is otherwise not successful.
The documentation on the project website indicates the following example as a delete response - https://github.com/blueimp/jQuery-File-Upload/wiki/Setup#using-jquery-file-upload-ui-version-with-a-custom-server-side-upload-handler
{"files": [
{
"picture1.jpg": true
},
{
"picture2.jpg": true
}
]}
Returning a similar json response with false instead of true doesn't seem to have any difference.

It seems like the UI plugin doesn't do anything with the response so any json response is valid and will have the same effect whether the delete was successful or not - the item will be removed from the file list. You'd need to modify the jquery.fileupload-ui.js code in order to do something specific with an error response.
What should I return in response to show error message on delete event for blueimp/jquery.file-upload-ui

Related

Axios's response, what's in it??.....const response = await axios

I'm using Axios in WP e.g.
const response = await axios.delete(universityData.siteURL + "/wp-json/wp/v2/note/" + thisNote.getAttribute("data-noteID"))
All works fine but what I don't understand is the structure / content of 'response'. How do I interrogate 'response'? I had assumed for instance if I did console.log('Axios response: ' + response.data) I'd get a nicely laid out JSON like OO output in the Chrome console panel. But all I see is: Axios response: [object Object]
I can do this response.data.userNoteCount and I get something sensible back. BTW 'userNoteCount' is a field I added to my JSON for my custom post type. But how else do I see all the content of response without specifically having to target it?
Thanks to another contributor elsewhere this is the answer:
When you do the console.log you're adding the JSON object to the
string of Axios Response, so the JSON object is being converted to a
string, hence the object Object.
If you do it as two seperate lines, like
console.log('Axios Response');
console.log(response.data);
Then it will be outputted as the actual object.
With it being an HTTP Request though, rather than outputting it into
the console, what I'd do is open the Network tab of the browser
development tools, and select the XHR tab, and then the request will
appear in there and you can inspect the full response body there
without having to log it.

IBM Maximo REST service POST not setting attributes on MBO

I have tried to create a record of my customized object through REST service in IBM Maximo.
The problem is that I created the record but I can't assign values to the attributes.
Next I will show what I did and what happened:
I have an Object Structure called oxidato that represents my customized object.
I did a POST using POSTMAN to this URL:
http://hostname:port/maximo/oslc/os/oxidato?lean=1
In the body section this is the JSON I was trying to send:
{
"attribute1":"205",
"attribute2":"206"
}
The record was created but none of the attributes was filled.
In my opinion, the REST service received the POST but canĀ“t read the body.
What am I missing? I add an image of the POSTMAN as example:
EDIT1: I update the POST in order to use the newest API RES (Thanks Dex!)
EDIT2: I add an image of the header
I have found that Maximo will often ignore incoming attributes that aren't in the Maximo namespace (http://www.ibm.com/maximo). You could go through the trouble of setting up your VALOR1 and VALOR2 attributes to be in that namespace, but it's easier to just tell OSLC to ignore namespaces. You do that by setting the "lean" parameter to "1".
In your case, go to the "Params" tab and add an entry with a name of "lean". Give it a value of "1" and then send your POST again. You should see "?lean=1" appear at the end of the POST URL along the top there, but your body content should remain unchanged.
EDIT:
On the other hand, it looks like (based on your URL) that you aren't actually using the newer JSON/OSLC REST API; It looks like you are using the older REST services. This IBM page gives you a lot of information on the newer JSON REST API, including the correct URLs for it: https://developer.ibm.com/static/site-id/155/maximodev/restguide/Maximo_Nextgen_REST_API.html.
You should change your URL to /maximo/oslc/os/oxidato to use the newer API that naturally supports JSON and the lean parameter described above. This does required Maximo 7.6 to use though.
EDIT 2:
The attributes are often oddly case sensitive, requiring lowercase. Your example in your question of "attribute1" and "attribute2" are properly lowercase, but your screenshot shows uppercase attribute names. Try changing them to "valor1" and "valor2". Also, these are persistent attributes, right?
The response code received back (e.g. 200 - OK) and the response body will detail the record that was created.
I think you are correct in that the body of the post request is being ignored. Provided there are no required fields on the custom MBO your POST is probably creating an empty record with the next value in the sequence for the key field but you should see that in the response.
The following POST should create a record with values provided for attribute1 and attribute2 and provide a response with the record's identifier so that you can look it up in Maximo and show the values that were stored for attribute1 and attribute2:
http://hostname:port/maximo/rest/os/oxidato/?_format=json&_compact=1&attribute1=205&attribute2=206
Response: 200 OK
Reponse Body:
{ "CreateOXIDATOResponse": {
"rsStart": 0,
"rsCount": 1,
"rsTotal": 1,
"OXIDATOSet": {
"OXIDATO": {
"rowstamp": "[0 0 0 0 0 -43 127 13]",
"ATTRIBUTE1": "205",
"ATTRIBUTE2": "206",
"OXIDATOID": 13
}
} } }
You may also want to turn on debug logging for the REST interface in System Configuration -> Platform Configuration -> Logging for additional detail on what's happening in the log file.

Building a Restful CRUD API with Node.js with Mongodb

i get the error:
{
"message": "Note content can not be empty"
}
The MongoDB is running and if i start $ node server.js, i get the messages:
Server is listening on port 3000
Successfully connected to the database
if i delete the following lines in note.controller.js. The Response-Status are 200-OK :
//return res.status(400).send({
// message: "Note content can not be empty"
// });
but the 'titel' contains the default content: "title": "Untitled Note".
I guess, it's a problem with the Middleware/ Mongooseenter code here.
Does anyone have a solution?
So, this error occurred to me when I followed the same tutorial, and the reason being that I was not experienced in using the Postman application.
The issue occurs when you choose the body as raw in the POST method by keeping the format of body as Text
For it to work properly, since the date should be in JSON format to be written into MongoDB as per the server configuration, we need to choose the raw body format as Json, as shown in the image below.

How to get a working document preview link from MS Graph

I am trying to get a preview link for the useres recent documents over MS Graph. Unfortunately the link the endpoint returns does not work.
To get the informations about a file I first call GET https://graph.microsoft.com/beta/me/drive/recent. Then I copy the driveID and the id of a document from the parentReference property.
To get the preview link I use the Endpoint POST https://graph.microsoft.com/beta/drives/<DriveID>/items/<DocumentID>/preview
and this works fine. But when I click on the link I get the error "This item might not exist or is no longer avaiable". The document exists on the SharePoint, otherwise it would not appear under "recent documents". The url looks like this: https://www.onedrive.com/embed?webUrl=xyz.sharepoint.com/sites/nameOfTheSite/docLibName&id=sites/nameOfTheSite/DocLibName&embed=xxx&authToken=xxx
I expect the response of the /preview endpoint should return a working url. Do I have to make some configurations on O365?
Many Thanks
The embed link (preview) does not look valid in your example since id parameter refers to container (library): sites/nameOfTheSite/DocLibName. It is not supported, instead embed link should refer to a file
Most likely the issue is due to itemId:
https://graph.microsoft.com/beta/drives/<DriveID>/items/<DocumentID>/preview
^^^^^^^^^^^^
in your example it seems refers to a library instead of a file. Make sure the proper itemId is specified.
For example, https://graph.microsoft.com/v1.0/me/drive/recent endpoint returns the following payload:
{
"value" : {
//another properties are omitted for a clarity
//...
"remoteItem": {
"id": "01ECKZLCWSR7F76B64KZFL7I3QGZVPJELU"
//...
"parentReference": {
"driveId": "b!79yKq-2MdkSDnQ7_1Pf3FOkRyDCajpRIvqtA7UrsEO-vu3D_qkpaT50Y6CMcSmFv",
"driveType": "documentLibrary",
"id": "01ECKZLCV6Y2GOVW7725BZO354PWSELRRZ"
},
}
}
}
where
remoteItem.Id - corresponds to item id for a file
remoteItem.parentReference.driveId - corresponds to drive id
Dont get confused with remoteItem.parentReference.Id which corresponds
to item id of library

Google Fit REST API "Unable to fetch DataSource for Dataset: xyz"

I'm testing out a few things in the OAuth 2.0 Playground and trying to get data in and out of Google Fit using their REST API
I have done this previously with success, I just didn't write down what I did.. now I've come back to make it a proper thing and can't get it working again.
I have access to Google Fit datasources via the dashboard. I can get a list of the dataSources that exist from:
https://www.googleapis.com/fitness/v1/users/me/dataSources
And that is successful. I have also created my own stream which has a single floating point weight value on it called
raw:com.google.weight:b6ac18c0:dten.sync
It already has data in it, I put it there last time I used it. I can select all that data by requesting a GET on the following
https://www.googleapis.com/fitness/v1/users/me/dataSources/raw:com.google.weight:b6ac18c0:dten.sync/datasets/0-1432193482000000000
It returns me all the data points I entered last time as JSON
I then try to PATCH the data adding my own data to the folliwng URL
https://www.googleapis.com/fitness/v1/users/me/dataSources/raw:com.google.weight:b6ac18c0:dten.sync/datasets/1432193482000000000-1432193482000000000
With this as a the request body
{
"minStartTimeNs": "1421912895000000000",
"maxEndTimeNs": "1432193482000000000",
"dataSourceId": "raw:com.google.weight:b6ac18c0:dten.sync",
"point": [
{
"startTimeNanos": "1421912895000000000",
"modifiedTimeMillis": "1421912895000",
"endTimeNanos": "1421912895000000000",
"value": [
{
"fPVal": 89.1
}
],
"dataTypeName": "com.google.weight"
}
]
}
But I get back
{
"error": {
"code": 400,
"message": "Unable to fetch DataSource for Dataset: raw:com.google.weight:b6ac18c0:dten.sync",
"errors": [
{
"domain": "global",
"message": "Unable to fetch DataSource for Dataset: raw:com.google.weight:b6ac18c0:dten.sync",
"reason": "invalidArgument"
}
]
}
}
I can't find any one referencing a similar anywhere soo I'm here
Also note if I miss spell my source it tells me off because they don't match the URL, if i include an empty list of data points I get the same error. I'm quite lost so I'm throwing it out there to see if anyone knows what that means
Thanks in advance
edit: i tried changing the hex code for my project's integer code and got an error about untrusted source. so i tried making a new test data source which works as expected. Slightly annoyed but guess I'll just start over..
OK I was stupid and didn't set up my own credentials in the OAuth settings in top right of the dashboard as it said to here. I forgot that bit -_- now I can access my own stream again and it shows my integer project id in the stream id not the hex one
https://developers.google.com/fit/rest/v1/get-started
Now I get invalid argument, but.. whatever >_<
edit 2:
invalid argument was because I have fPVal instead of fpVal and modifiedTimeMillis mills is not supposed to be submitted, obviously