Bridge RESO OData API - visual-studio

Im trying to use the OData Connected Service in Visual Studio to connect to a OData Feed in Bridge (RESO Feed).
However, If I try and pull the metadata directly from a URL, it has errors Adding OData Connected Service to the project failed: Could not get CLR type name for EDM type 'memberMediaEnums.ResourceName'
So I went ahead and downloaded the XML file and tweaked it to get rid of the errors and warnings. This includes Removing Entity references with no parents and removing attributes that were not supported like Precision.
Once its all loaded and the reference file is created I tried pulling data. The endpoint works and data is retrieved, but it is not thrown into the object as i would expect.
IEnumerable<Property> properties= await context.Property.ExecuteAsync();
foreach (var property in properties) //Errors trying to make a property
{
Console.WriteLine("{0} {1}", property.YearBuilt, property.ListPrice);
}
When I try and loop over the object I get this error:
The context URI 'https://api.bridgedataoutput.com/api/v2/OData/imls2/$metadata#Property' is not valid for the expected payload kind 'Resource'.
Where I am confused, is in the name Resource There is no object or entity in the Reference file or in the XML scheme that references that word. I'm not sure if its coming from OData services or the reference file it created. The call stack does not contain anything but the exact line of the loop.
Any insights would be helpful but i know its a long shot. Let me know if I need to provide more details.
Thanks

Related

How do I return dynamic column stored procedure results with ASP.NET Web Api OData provider?

I'm banging my head against the wall with this one.
I'm trying to build an ASP.NET Web API OData service for a customer. The data returned comes from a SQL Server stored procedure that returns data with different structure every time (the columns may change on every execution).
I tried to do it with an entities model but of course - the whole point of EF is a pre-known data model and I found it impossible to get it to work.
I also tried using ADO.NET - get the stored procedure's data using a SqlDataReader and building a DataTable object with the columns (that change every time the stored procedure is executed) but I keep getting configuration errors, http errors and it looks like I'm not getting it right. Getting the stored procedure data worked but something with getting the data to be returned to the OData client doesn't work properly.
Google for several hours and tried several approaches but nothing works. I'm using Visual Studio 2013 (maybe it's too old a version?)
Did anyone succeed in getting variable structured data to be returned from a Web Api OData controller? Any sample projects that show how to do it?
My client is Excel (importing from an OData feed).

Visual Studio 2019 - Connected Service Reference - OpenAPI is generating duplicate types

I am trying to generate an OpenApi service reference in Visual Studio 2019. .Net 5.0.
Right clicking project >Add>Connected Services>+ Service References
I am using NetDocs api "https://api.vault.netvoyage.com/v2/swagger/docs/v2".
Result: I get generated c# client code but it is duplicating the types with the errors below.
Severity Code Description Project File Line Suppression State
Error CS0102 The type 'v2Client' already contains a definition for '_settings' OpenAPITest C:\Users\dryfus\source\repos\OpenAPITest\obj\v2Client.cs 4941 Active
Error CS0579 Duplicate 'System.CodeDom.Compiler.GeneratedCode' attribute OpenAPITest C:\Users\dryfus\source\repos\OpenAPITest\obj\v2Client.cs 4936 Active
Error CS0102 The type 'v2Client' already contains a definition for '_baseUrl' OpenAPITest C:\Users\dryfus\source\repos\OpenAPITest\obj\v2Client.cs 4939 Active
Error CS0102 The type 'v2Client' already contains a definition for '_httpClient' OpenAPITest C:\Users\dryfus\source\repos\OpenAPITest\obj\v2Client.cs 4940 Active
Is there a way I can get this to work with the connector way without the duplicates? Or even cli? Any suggestions on why it is creating the duplicates?
I had the same issue, it turns out the code generation didn't like enpoints with an underscore in its operationId. Lucky for me, the service I was consuming was also part of our code, so I could just go to the Swagger configuration in the API side and change the CustomOperationIds setting.
I downloaded and use NSwagStudio to generate the client code and did not have the same issue that the Visual Studio connector had when generating the code.
https://github.com/RicoSuter/NSwag/wiki/NSwagStudio
It is actually caused by this option
OperationGenerationMode:MultipleClientsFromOperationId
MultipleClientsFromOperationId : Multiple clients from the Swagger operation ID in the form '{controller}_{action}'
However, if your classname is set as a static name, it will cause an error like you have.
The correct solution should be change the classname to something like
ClassName="{controller}ServiceClient"
So it will generate different classes.

Odata endpoint returning 404 bad request when the "$" in filter is encoded

I have an Azure Mobile service with a .Net back end.
In the backend the data object use proper case. for example, MemberNumber.
In the azure client the view models use pascal case memberNumber.
I am using a library that creates an ODATA request and I get:
The query specified in the URI is not valid. Could not find a property named 'memberNumber' on type 'arenaapi.DataObjects.Members'.
That happens with this get:
/tables/members?%24inlinecount=allpages&%24orderby=memberNumber
If I change that the MemberNumber it works.
However, also, if I change the request to:
/tables/members?%24inlinecount=allpages&$orderby=memberNumber
It also works. It seems that the model binding parser is working differently if the $ is encoded or not.
Is there any way I can fix this server side so the encoded request won't return a 400 without changing the memberNumber to MemberNumber?
All the other stuff, posting, patching, etc is properly binding the pascal cased JSON post to proper cased c# data objects.

Server Error with the griffin.mvccontrib package in asp.net

In order to be able to translate my data annotations in my model with a resource file, I saw that many people recommend the solution offered by jgauffin.
However, when I follow the localization tutorial my project cannot launch.
The problematic code is this one, which is supposed to go in the Global.asax.cs file:
ModelValidatorProviders.Providers.Add(
new LocalizedModelValidatorProvider(stringProvider)
);
It says that the LocalizedModelValidatorProvider constructor does not take any arguments, which is also shown by other tutorials.
But when I change the line like this:
ModelValidatorProviders.Providers.Add(
new LocalizedModelValidatorProvider()
);
I get the following error in the browser:
Attempted to access an element as a type incompatible with the array.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array.
The griffin.mvccontrib packages were installed with NuGet under Visual Studio 2012. Any idea what I am doing wrong ?
You might find this link helpful
Here is how I did the registration in the above link:
ResourceStringProvider myResouceFile = new ResourceStringProvider(ModelsResources.ResourceManager);
//ModelsResources is my resource file generated class
GriffinStringsProvider griffinStringsProvider = new GriffinStringsProvider(myResouceFile);
ValidationMessageProviders.Clear();
ValidationMessageProviders.Add(griffinStringsProvider);
ModelMetadataProviders.Current = new LocalizedModelMetadataProvider(myResouceFile);
ModelValidatorProviders.Providers.Clear();
ModelValidatorProviders.Providers.Add(new LocalizedModelValidatorProvider());
Make sure you are including the right assemblies
using System.Resources;
using Griffin.MvcContrib.Localization;
using Griffin.MvcContrib.Localization.ValidationMessages;
Also the assembly for your Resource file.

Programatically retrieve an attachment stored on a note on a CRM 4.0 entity

How would you suggest working with files that is stored on the note of a entity in Crm. Could you write a generic method that will enable you to access any type of file? Or would it be better to have a method for dealing with each type of file?
For example, we are going to be saving a mix of swf files and xml files on the entity, so would it make sense to have a method each for example:
GetXmlFilesOnAccount(accountid)
GetSwfFilesOnAccount(accountid)
When you upload an attachment to CRM the mimetype is also saved as part of the record information.
The following link contains a nice example of how to download the attachemt using a single method. http://crmscape.blogspot.com/2009/10/ms-crm-40-sending-attachments-to.html
The post is missing the actual query needed to retrieve the annotations but you can tell what columns are required from the method signature.
My suggestion using your methods:
* GetXmlFilesOnAccount(accountid)
* GetSwfFilesOnAccount(accountid)
Retrieve account activitypointers by regardingobjectid(in your case accountid guid)
Loop through returned activitypointers
Get attachments for each activitypointer (activitypointer.activityid = activitymimeattachment.activityid)
Store attachments (disk, etc)
You don't even need two methods. You can retrieve all attachment file types for a given note (annotation) with a single method.
Hope this helps.
I recently started an Open Source Project on CodePlex to accomplish exactly that. Feel free to check out the Project's Web Page at:
http://crmattachdownload.codeplex.com/
You can also view the source code under the "Source Code" tab of that same page.
Pete

Resources