Don't get result from MVC Web API with EF, 504 Fiddler - Receive Failure - asp.net-mvc

I’m using the MVC Web API to expose my data out of my local database with Entity Framework 5. The database that I use is the Microsoft AdventureWorks2012 database.
When I expose one entity, it all works fine and I see JSON result with Fiddler. But when I add multiple entities which have relationships and when I for instance want all the sales person and the stores which belong to the sales person (return context.SalesPerson.Include(“Store”)), I get the next message in Fiddler “[Fiddler] ReadResponse() failed: The server did not return a response for this request.”, 504 Fiddler - Receive Failure.
I don’t now if I have to transform the entity to some type or set a feature in EF, anybody got a idea/solution?

It looks like a circular reference issue in the model. Please try the solutions in my blog http://blogs.msdn.com/b/hongyes/archive/2012/09/04/loop-reference-handling-in-serializer.aspx

Related

OData in Datafactory

I have a task toget some data from an external supplier.
They have a Rest OData API. I have to connect using a subscription-key(APIKey).
When creating the OData LService, I add an Auth Header: "subscription-key" and in the Value field, I enter my key. After saving, I create a new dataset, and the OData LinkedService, provides me with the remote tables. I can choose the table I want and after that I create a pipeline to copy data from that table to my Azure SQL server.
This works fantastic :-)
However, after closing my browser and re-open it, the subscription key that I have entered earlier on the linked service, is now replaced with stars as it is a securestring. When I now run my pipeline, it will think that my key is the ten stars that have replaced my real key.
What am I doing wrong here ?
Also I would prefer to get my value from the KeyVault, but it seems that this is not possible on ODat connections....
Hope someone is able to provide some insight here :-)
BR Tom
From my testing I did not get any error on re-running. However coming to dynamic keys - I was not able to achieve it using the ODATA linked service.
Alternatively, if you can hit the ODATA endpoint with REST / HTTP Connector
You could - have a Web Activity to get the keys from the Key Vault and Set in the Variable.
WEB Activity URL : https://<your-keyvalut-name>.vault.azure.net/secrets/<your-secret-name>;
You could access the output of the web Activity using : #activity('Web1').output.value & Store in a variable.
You can reference this variable as the SUBSCRIPTION KEY for the subsequent steps in the REST/HTTP dataset.
You could pass it along the additional headers

Query deleted records via SF OData API?

I am replicating the Successfactors Employee Central Data (including FO, MDF, BG elements and etc.) via OData API to local database for third party integration.
It is able to trace changed records by filtering last modify date. However, the deleted record is not able to capture from OData API. Hence I cannot delete the record in my local database when corresponding EC record is deleted.
Is there any way I can get the deleted records from the API or other sources? Thanks.
OData API is not able to handle this task.
Extract from SF OData API doc:
Don't use our OData APIs when:
● Your system cannot consume either OData APIs or SOAP for an initial data load. In this case, you would go
for Import/Export with a CSV. Automation via FTP would also be a possibility.
● You need employee replication field level delta, snapshot, or read modified employees only, then SOAP Compound Employee API is your tool of choice. You can find more information in the guide Implementing the Employee Central Compound Employee API.
● You only need to read data, then the SOAP Compound Employee API would also be your tool of choice.
However with SFAPI (SuccessFactors CompoundEmployee API) it's easy. SFAPI has a special parameter changedSegmentsOnly that does exactly just what you want, the API returns only changed segments with an action code not equal to NO_CHANGE in delta transmission.
You make a query, for example, for changed employee data:
<urn:query>
<urn:queryString>select person,
personal_information,
address_information,
email_information,
phone_information,
employment_information,
job_information,
compensation_information,
paycompensation_recurring,
paycompensation_non_recurring,
direct_deposit,
national_id_card,
payment_information
from CompoundEmployee
where person_id_external = 'cgrant'
</urn:queryString>
<urn:param>
<urn:name>resultOptions</urn:name>
<urn:value>changedSegmentsOnly</urn:value>
</urn:param>
<urn:param>
<urn:name>maxRows</urn:name>
<urn:value>50</urn:value>
</urn:param>
</urn:query>
This API query will return you all the employees that were changed or deleted.
After that you can filter your response by that field.
ADDENDUM: any change to MDF entity, both standard and custom, can be tracked via OData Audit logs. How to enable them:
Go to this setting in API center
Enable this switch. It can be enabled for SFAPI as well
This way all API calls payloads will be saved and you will be able to see what entity was changed with each call
Prerequisite: the object must be visible by API and MDF version history must be enabled
More about API types for SuccessFactors:
SAP Note 2613670
OData API reference Guide
SFAPI reference Guide

SAP HANA XS Engine Odata Service doesn't let me Create/Update/Delete

I hava a SAP HANA XS Server with some DB Tables and an OData service. I am able to connect to the OData service and to read data. As soon as I try to Create/Update/Delete data I get the 403 - Forbidden Error.
Actually my user has the required rights to execute all of the mentioned actions (I created data using the SQL command line in HANA Studio). When I try the same with the SYSTEM user I get the same result.
If your .xsaccess file looks like this:
{
"prevent_xsrf": true,
...
}
you have to fetch an XSRF-token before you modify your entity. Reading the entity works without.
Such a token can be obtained by executing a GET to the service endpoint with following header X-CSRF-Token=Fetch. The response contains a header like this X-CSRF-Token=13DC4988AEAA95.... If you execute your e.g. POST now with the just obtained token it will work.
I am guessing that your OData service is defined to not allow modifications of the data.
From the SAP HANA Developer Guide:
By default, all entity sets and associations in an OData service are writeable, that is they can be modified with a CREATE, UPDATE, or DELETE requests. However, you can prevent the execution of a modification request by setting the appropriate keyword (create, update, or delete) with the forbidden option in the OData service definition. The following example of an OData service definition for SAP HANA XS shows how to prevent any modification to the table myTable that is exposed by the OData service. Any attempt to make a modification to the indicated table using a CREATE, UPDATE, or DELETE request results in the HTTP response status 403 FORBIDDEN.
service {
“sap.test::myTable”
create forbidden
update forbidden
delete forbidden;
}

HTTP code when deleting records

I am using Ruby on Rails and I am trying to understand all the subtleties of HTTP codes to bring my app with standards, and I'm facing the following case.
Let's say I have a database with two tables, Companies and Employees.
If users try to delete a company with no employee, it is deleted and server sends code 200.
If users try to delete a company with employees, it is not deleted and server sends a message ("There are employees linked to this company..."). In this case, what code does server have to send ? I was thinking of HTTP 4XX but in my opinion, it is not a client error.
Use the 409 Conflict error code. It indicates that the request could not be processed because of conflict in the request.
Once the employees are gone then the conflict is removed and the delete will work. You can think of it as a client error in the sense that it is a conflicted request from the client.
If the client is not allowed to use the DELETE method on companies with employees, I would suggest 405 Method not allowed. Include an explanation of why in the response body.

How to escape a period (.) in WCF Data Services QueryString

I have a WCF Data Services service that exposes a set of ICD codes. The primary key for the underlying table and the data set that WCF provides access to is a varchar or string in C#.
The service works properly if I have a query like this:
http://somehost/someService.svc/IcdSet('001')
If, however, the ICD code happens to have a . in the identifier as many do, the service fails. Here's an example of one that won't work (IIS gives a 404 - Not Found response):
http://somehost/someService.svc/IcdSet('001.1')
So the question is how can I escape the period or properly pass it to WCF Data Services? It must be interpreting it as a different type of filter condition.
Note: The code for the underlying class seems irrelevant to the question but I can provide it if needed.
Edit: My guess at the moment is that IIS is trying to find a file that ends with .1') which is then producing the 404 error. But how can I tell IIS that it shouldn't be looking for files as these are all data queries?
check this out http://blogs.msdn.com/b/peter_qian/archive/2010/05/25/using-wcf-data-service-with-restricted-characrters-as-keys.aspx
Also might be of interest if you're using .Net 3.5 http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=5121

Resources