Komengem
Komengem

Reputation: 3774

How can i use Fiddler to debug Web API Post and Put methods in a one-to-many or many-to-many relationship?

I have been playing with Asp.Net Web API in Visual Studio 2012. I have 2 classes, Continent, which then has a collection of Countries. I can easily debug continent Post and Put methods. But i can't seem to find a way to assign Continent to a Country object when i create it.

Does anyone know how to debug Web API Post and Put methods in a one-to-many or many-to-many relationship? Every option i have tried up to this point, gives me an error that:

eg: {"Name":"Canada1","Continent":"1"} says;

Object reference not set to an instance of an object.

NOTE: I will also take suggestions to a different Web Debugger you are familiar with as long as it works the in situation described.

Upvotes: 0

Views: 1609

Answers (1)

T.S.
T.S.

Reputation: 19376

What your data relationship is, has no concerns in relation to Web Api, Fiddler, etc. Best way is to have your specific controllers for each entity type and use simple view models to transport data in the form of JSON. It is possible though to create a view models, in your case, Continent model, that contains collection of Countries. In JSON it will be represented as collection/array. Now, how you populate the model in your controller/business object - doesn't matter.

Using Fiddler is the same as for simple models. You will need to provide JSON which has Continent properties and Collection of countries with their properties. Make sure to setup content type in headers and it should work fine. It worked for me, like a charm.

Upvotes: 1

Related Questions