Content Negotiation fails on using EDMBuilder Web Api 2 (ODATA service) - asp.net-web-api

I am currently working on an OData Web API 2 service using EF6 with a code first approach. My controllers all derive from the base ODataController. I have made use of Ninject for DI and Owin.
I am trying to expose OData but for some strange reason on using the EDMBuilder, content negotiation fails even on a browser, giving the HTTP 406 error.
Content negotiation works when I use the ODataConventionModelBuilder, but I cannot use this as I will not be able to use breeze's client side features.
Wondering if anyone has come across such an issue before while using the EDMBuilder.

Looks like this is documented :(. It is there in the Breeze documentation at the following link with a suggested workaround: http://www.breezejs.com/documentation/odata-server

Related

How to use REST API with FaunaDB?

I have created a collection in my Fauna database. I also made an index that returns all the data in that collection. I want to know if there is a way to get JSON REST API to work with this data. What I mean by this is I want a URL that I can 'GET' using XMLHttpRequest and then parse into JSON.
You might say that Fauna is "HTTP native". All of the language drivers (JS, C#, Python, etc.) are built on top of http requests. That is, there are no special connections or connection-pools to maintain. You can get pretty far with using the JS driver in the browser, for example, without using a server.
But to answer your question more directly, there are many ways to serve a REST API, and it is going to depend on how you want to serve the API.
Examples
AWS
Here is a blog post on how to set up a REST API with AWS App Runner, for example.
https://fauna.com/blog/deploying-a-rest-api-with-aws-app-runner-and-fauna
Vercel and Netlify
There are also some example apps on github that demonstrate using a REST API with
Vercel:
https://github.com/vercel/next.js/tree/canary/examples/with-cookie-auth-fauna
Or Netlify:
https://github.com/netlify/netlify-faunadb-example
Both of which host serverless functions for you to create a REST API.

Spring RestTemplate 404 error for large POST request to .NET Core REST api

I am trying to make a Java (Spring) application which invokes a REST api in a .NET Core application. Everything seems to work in the general case, but now that I am making a POST with an XML string which takes up 80 megabytes on my system, the RestTemplate produces a 404 error code saying "Not found". I have tried to remove the POST size limit in both the .NET Core application (by using the DisableRequestSizeLimit attribute in the API controller) and in the Spring configuration (by setting the variable spring.servlet.multipart.max-request-size to 200MB in application.properties). Neither of it seems to work. Is there some way to fix this? I am willing to use an alternative to the RestTemplate, if that would make sense. I am using the exchange method of the RestTemplate object.
Not found is a general error, if the problem would be sending the request, other problem will happens. I highly recommend you to test the rest api with another tool, like Postman or Insomnia. After that works with the tool try with your client application.
Clarification:
spring.servlet.multipart.max-request-size is for api in your Spring application, no for requesting another services.
Due to Milton BO's answer, I made a request in POSTMAN, which gave me a more detailed error response from the ASP.NET Core app. And it told me to change the maximum allowed post size in the web.config (or appplicationhost.config) file for IIS Express. Furthermore, I am now using the Kestrel server instead of IIS Express, so the DisableRequestSizeLimit attribute now works as expected.

Ajax call by HTTP request in angular 2

I am trying to load some user data from database to my angular 2 page. I am doing the angular 2 as separate application and using ReST APIs for get data. My back-end is designed using spring and spring boot and maven tool. So when I am using my angular 2 page, is it possible to load my data from spring boot micro services using Ajax call? Angular 2 supporting Ajax call for HTTP request?. If possible, can anyone share any reference link for exploring the Ajax with http request in angular 2?
So when I am using my angular 2 page, is it possible to load my data
from spring boot micro services using Ajax call?
Yes, that's what Angular is built for, single page applications which calls back Restful services for data. Only thing is I wouldn't phrase it as AJAX call (sounds like an old school :) ) I would rather call it as REST service call.
Angular 2 supporting Ajax call for HTTP request?
Yes it does, that's what Angular is built for
If possible, can anyone share any reference link for exploring the
Ajax with http request in angular 2?
Any sample Angular App with a backend will serve as an example. You will be able to find lots of examples by just googling it. Even if I am providing the code here, it will become irrelevant overtime as angular library itself is evolving. So, I would say, wise thing to do is, check their official website (angular.io, not angularjs that's angular 1.X, ancient stuff) and look for http call examples (eg. tour of heroes project).

Configuring WCF for Web Browser Access

I'm fairly new to WCF but am technically competent.
I am having trouble getting WCF to play nicely. I currently have a WSHttpBinding set up to a service and it is working when using the WCFTestClient supplied with VS2008. What I would like to do is have the service accessible within the browser.
I currently return a JSON response from my service but am unable, as of yet, to access the data via. a URL. I have seen lots of internet tutorials where they seem to be accessing data a bit like this (note the bolded section):
http://localhost/Service.svc/MethodName?param1=value1&param2=value2
If I try and do that I get a 404 - I am guessing it is looking for a literal file but don't know how to fix it.
Any help you can give would be great, thanks!
You can't do that with WSHttpBinding... you need to expose an endpoint using the WebHttpBinding and have your contract correctly specify the right uri template in the [WebGet] attribute. Here are some pointers to get you started:
Rest in WCF
WebHttpBinding example
WebHttpBinding and JSON

How to call Java web service (JAX-WS) from AJAX?

I am developing java web services (JAX-WS) to insert data into mysql DB and retrieve it. This web service has two methods i.e. fetchFromDB and insertIntoDB. Services seems to be running fine when I test them using netbeans IDE.
Address: /CalculatorWSService
WSDL: /CalculatorWSService?wsdl
but when I try to access it using AJAX's xmlHttpRequest object by providing url http://localhost:8080/CalculatorApp/CalculatorWSService. It is not able to access it. I have developed C# web services and It has been so easy to access them with a url but java web services don't seem to follow that.
My question is
What url to use to access the web service operations in AJAX? (Do I need to use '?wsdl' in the url?
Is there a javascript ajax library to easily access JAX-WS web services?
Apache Axis web services are a better choice over JAX-WS?
Please help me, Thanks, Jay
I was having the same problem of yours, couldn't invoke a Jax-ws web service from Javascript, but i've found a way to do this.
The Url to use can be your same (EndPointAddress) "http://localhost:8080/CalculatorApp/CalculatorWSService"
but when you create the XMLHttpRequest object from javascript you have to:
* Use the POST method to open the URL , i tried with GET but it didn't work for me.
* Set the SOAPAction Request Header to the one in your wsdl, even if its empty "".
* Be very careful with the request body to send, the soap Envelope must be correct.
hope this can help you!.
Bye.
Paul Manjarres.
From the client's perspective, I wasn't expecting significant differences between Axis and JAX-WS. Everything the client needs should be in the WSDL.
One thing that sometimes happens is that the URL used when developing a WebService references the develpoment host and port (and maybe even the ContextRoot) When deployed to a particular server any of those could be changed. Ideally a new WSDL could be created with new "binding" information.
My first step would be to point a browser directly at the Web Service you want to invoke. In my environments that returns a nice "Hi this is a Web Service" kind of message. If you get 401 not found errors then you just need to study exactly how the web service was deployed. Was a different port or context root specified?

Resources