SAPUI5 invalid MIME part type with Remote oDATA Service - odata

I need help showing the data from my own remote server with oDATA.
When I want to show the data in the view, I get the following error
invalid MIME part type.
These are the Captures of Error
my https://******/$metadata?
My Table control from SApui5 Course App example
Error when executing the application
And Console error
When I insert this.getModel().setUseBatch(false) in the init : function () of the Component.js, it does not give me the error, nor in the console, but it does not show me the records either .. Can someone give me an idea?

It's an old question, but recently I've got the same error with batch request processing and in my case the root cause was that when building batch processing response with content type multipart/mixed you have to use CRLF as a text line separator ('\r\n') and not only '\n'. See also here in multipart response specification. The hard part was that correct and incorrect responses look absolutely identical when debugging.

Related

Why is this URI producing a runtime error in the OData service?

The following URI triggered an error in the public OData service:
http://services.odata.org/V4/Northwind/Northwind.svc/Suppliers?$filter=Address eq '<A'
Entity type Supplier contains property Address of type Edm.String. So, the value of Address may contain any UTF-8 character from the definition (see section 6. Primitive data types).
The server responds with:
Runtime Error: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons).
Is the there something wrong with this URI or it is really a problem on the server side (e.g. inappropriate parsing of the $filter query option)?
You should encode your query URL, e.g. with help of
http://prasannaadavi.com/2014/06/handling-special-characters-in-odata-queries.html
How are special characters handled in an oData query?
In your special case you should try encoding "<A" with "<A"
--> found in https://web.archive.org/web/20150101222238/http://msdn.microsoft.com/en-us/library/aa226544(SQL.80).aspx)

Rails RESTful API: the proper error format when content negotiation fails

What error format must be used by RESTful API when content negotiation fails (ActionController::UnknownFormat is raised):
when a controller responds to the only one format (e. g. JSON) and the user has requested another one (e. g. XML), should the error be generated as JSON object or XML one?
when a controller responds to several formats and the user has requested neither of them, which one should be used during error generation: one of the 'known' by the controller or the one, having been requested by the user?
I think you are under no obligation to respond to any invalid request with the same format as the request was made. Imagine getting a request with payload in unknown binary format - what are you supposed to do in such a case.
ActionController::UnknownFormat should trigger a 406 Not Acceptable response, probably will in Rails 5.
You should rescue the ActionController::UnknownFormat and respond with proper HTTP code as well as set an Accept header listing all formats that your API supports (if Rails doesn't do it by default, I'm not sure)

Most efficient way to handle failure retry with multiple possibilities in Objective-C

I am adding code to my iOS app to deal with errors when it interact with a server. The error handling varies based on type of failure.
For e.g: The error could be receipt of a non 200:OK response. In which case, I want to use the response code to determine the retry algorithm
Or the error could be a timeout
Or the error could be based on the value of a field in the JSON body returned from the server.
Also, the error handling would be different depending on whether the failure occurred during registration or during data transfer etc.
I am thinking of having a generic function to avoid repeating code in several places
Basically it will take two arguments
1. A failure code that identifies sub-type of error and
2. A JSON body whose content will depend on the failure code argument
Is this approach ok or is it better split it into individual functions?
The approach with one function is OK, but as you said, sometimes you will have message as body from JSON response, sometimes you will have error as timeout, sometimes as key from the 200 OK response.. It means you need a parser function which will decide what to pass as the error message, because I'm afraid that you will end up with huge function doing everything at once. I would:
a) Split this function to parser & error show
or
b) Do the parsing in the network handler, but it might copy the code across the application.

ASP.NET WEB API 406 error:for POST request using Media format

I am very new to web api stuff:
I am getting an error
406: Not Acceptable
error message in asp.net web api rest service.
In my rest service I’m using media format for my customized XML output, to get customized output.
I’m registering my formatted media in Global.asax page.
GlobalConfiguration.Configuration.Formatters.Clear();
GlobalConfiguration.Configuration.Formatters.Add(new mynewformat());
all my methods are post methods with typed object as parameter and parameters are accepts from body.
Whenever I try to test the service… Getting 406: Not acceptable error message.
can anyone please help me ... what could be the reason for this....???
I did notice couple of interesting points here...
If I’m commenting below line then I’m getting 200 (OK) status code (which is fine.)... but format is not applying to output.
GlobalConfiguration.Configuration.Formatters.Clear();
If i'm removing parameters in my service method.. Then its working
fine..
I request everyone.. Please guide me what could be the reason/work around/solution/fix..for this issue.
Note:I don't want accept parameters from URI so i made it to accept from frombody only.
Thanks.
There is a lot more to implementing a custom format than just adding it to the configuration formatters. It starts with having to change the media-type header to a new custom type of your choosing (like "application/myNewFormat") for all requests, for the client. On the back end, you have to implement a new MediaTypeFormatter that can handle the serialization. This involves a bit more of code.
A good example of this resides here, it can easily be stripped to boiler-plate code:
http://www.codeproject.com/Articles/559378/Implementing-Custom-Media-Formatters-in-ASP-NET-We

I got 'Document is empty' when using grape

all
I got the error when using grape.
This page contains the following errors:
error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.
in fact, My api works and return the xml well. and after sometime's running , it start to buggy. show that error. my server is nginx + passenger. rails2.3.8. + grape. any help?
The error is from Chrome, displayed when content-type is xml and the xml is not well formed, or in your case as the error indicates, empty. Your api will still work from clients (such as curl) that do not parse and verify the content type.
It's best to hit your api with curl instead of a browser when you encounter something odd.

Resources