I set up my odata service with Node, MongoDB and JayData. When I hit http://localhost:8000/odata/findash.svc/$metadata in my browser I get the metadata exactly as I would expect.
In the browser console I execute this sample code:
var manager = new breeze.EntityManager('odata/findash.svc');
var query = new breeze.EntityQuery()
.from("accounts");
manager.executeQuery(query).then(function(data){
console.log(data);
}).fail(function(e) {
alert(e);
});
An alert pops up with the message: Error: Metadata query failed for: odata/findash.svc/Metadata; Not Found
The net tab confirms that Breeze is hitting odata/findash.svc/Metadata which produces a 404 instead of odata/findash.svc/$metadata which works fine.
Is there a way to configure this behavior in Breeze or is the problem with my odata setup?
I assume that you meant OData and not JayData in your question. Breeze and JayData are two different products. If not then I'm not sure I understand the question.
I think that you haven't told breeze to use the OData endpoint. By default breeze uses a WebApi endpoint. You can change this via the breeze.config like this:
breeze.config.initializeAdapterInstances({
dataService: "OData", ...
});
Breeze supports both OData and a WebApi endpoints. The OData endpoint ( per the OData spec) returns metadata from '$metadata". The webApi endpoint returns metadata from 'Metadata'.
See: http://www.breezejs.com/documentation/odata
Related
I am successfully retrieving an access token for the Microsoft Graph API with the App-Only flow, but the produced token can't seem to access anything.
Here is the authentication code I'm using:
var clientApp = new ConfidentialClientApplication(
identifier,
authority,
"urn:ietf:wg:oauth:2.0:oob",
new ClientCredential(secret), null, null);
var scopes = new string[] { $"{identifier}/.default" };
AuthenticationResult authResult = await clientApp.AcquireTokenForClientAsync(scopes);
return authResult.AccessToken;
From that, I do indeed get a token, but when I try to use it, it throws Access token validation failure. Here's the test query I've been using:
var users = service.Users.Request()
.Filter($"mail eq '{resourceIdentifier}'")
.Top(1)
.GetAsync();
users.Wait();
For the API baseUrl, I was providing: https://graph.windows.net/{appId}. I did add api-version=1.6 to the query string (manually, as I don't see an option exposed through the Microsoft.Graph NuGet library). I had earlier tried https://graph.microsoft.com/v2.0, also to no avail.
Anyway, given the error messages about validation failure, I have come to believe that our (possibly tenant-specific?) API URI might be wrong. Could that be it? What am I not seeing?
Update
The solution had two components. The first was as mentioned in the accepted answer. The second was that the scope should be, simply, https://graph.microsoft.com/.default, despite my API calls being tenant-specific.
You're conflating two different APIs here.
The graph.windows.net URI is for the Azure AD Graph which is an entirely different API. For Microsoft Graph the URI should be graph.microsoft.com.
There is also isn't a /v2.0 of Microsoft Graph today. The publicly available versions are /v1.0 and /beta. Also note that when using the Microsoft Graph Client Library for .NET you shouldn't need to provide a baseUrl as it already defaults to https://graph.microsoft.com/v1.0.
i am trying to connect sapui5/openui5 ODataModel to an odata-server. I want to use a nodejs server with package simple-odata-server. Unfortunately this odata server provides metadata only in xml-format. But sapui5 tries to load metadata in json-format.
Before i switch to another odata server, i want to check, wether sapui5 can load metadata in xml-format. I tried to create the model with several parameters, but ODataModel still tries to load metadata as json.
var oModel = new ODataModel("/odata", {
"metadataUrlParams": "$format=xml",
"json": false
});
Does anybody know, wether i can switch to $format=xml
Thanks in advance,
Torsten
As far as I know the OData protocol metadata is always provided as XML, never seen metadata in JSON format. Also my n-odata-server Qualiture mentioned in the comment above does it. But I never had problems with SAPUI5. It requests the metadata, gets the xml stream and works with it.
Since the metadataUrlParams parameter is of type map I'd suppose it would at least do what you intend like this:
var oModel = new ODataModel("/odata", {
"metadataUrlParams": {
"$format": "xml"
}
});
https://sapui5.hana.ondemand.com/sdk/#docs/api/symbols/sap.ui.model.odata.ODataModel.html#constructor
I tried to update one entity in my angularjs client using breezejs library. After calling saveChanges(), it can actually save back in the server and fetched on the client. However, the server did not return the response back. The saveResult.entities is undefined and pop up an error for me. When I took a look at the docs, it mentions 'Some service APIs do not return information about every saved entity. If your server doesn't return such information, you should add the pre-save, cached entity to saveResult.entities yourself'. Could anyone provide an example of how to do this?
This is the code when i am trying to do an update.
manager.saveChanges(entitiesToSave, null, (saveResult) => {
const savedRes = saveResult;
savedRes.entities = entitiesToSave;
return savedRes;
}).then(saveSucceeded);
On the server, you would need to construct the response for an update similar to the way it is for a create:
response.setContent(...); // entities
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
I am using a doc data payments gateway service and when I try to give it a request to create an order it throws the following exception:
XmlSerializer attribute
System.Xml.Serialization.XmlAttributeAttribute is not valid in
version. Only XmlElement, XmlArray, XmlArrayItem, XmlAnyAttribute and
XmlAnyElement attributes are supported when IsWrapped is true.
I don't think it is an exception that has anything to do with the service. What am I doing wrong on my side of implementation. Can anyone help me with that?
EDIT
I have used DocDataPayments gateway and used the wsdl refrence they give to make the call.
The create call I am making is as follows:-
PaymentServiceSOAPClient client = new PaymentServiceSOAPClient();
createSuccess success = new createSuccess();
client.create(merchant, strMTID, paymentPreferences, menuPreferences, shopper, totalGrossAmount, billTo, "description", "Thanks for your purchase", true, new paymentRequest(), new invoice(), new technicalIntegrationInfo(), Convert.ToDecimal(0.9), out success);
I think, you are using wcf default serializer to make proxy classes.you can try with DataContract serializer instead default serializer.
In our odata service implementation, the autogenerated metadata can be accessed at:
https://<ourserver>/v1/$metadata
But the BreezeJS tries to access it from https://<ourserver>/v1/Metadata. And it gets a 404 error as the metadata is not served at this location.
How to instruct BreezeJs to find the metadata at any given URL?
The code entityManger.fetchMetadata() is trying reach metadata at https://<ourserver>/v1/Metadata and not at where it is available https://<ourserver>/v1/$metadata
You need to tell Breeze that you are using OData, by default it assumes WebApi. So:
breeze.config.initializeAdapterInstances({ dataService: "OData" });
Also see: http://www.breezejs.com/documentation/odata