problems in posting/creating in the stockqoute example

May 5, 2014 at 8:17 AM

I have been working on a oslc-client and a oslc-provider based on the stockqoute example for a while now.
I have created a controller, named "reqtest". As an example, to call "Get" you use the url "http://localhost:7077/api/reqtest/" I have also got "Put" and "Delete" to work. But when I try to use the OSLC-client to create a OSLC resource the Controller will not step into the "Post" method, instead I end up in the "JsonHelper.cs" and getting a "ArgumentNullException".

Here is the OSLC-client code:
        protected void CreateReqBtn_Click(object sender, EventArgs e)
            SWObject req = new SWObject();

            req.SetServiceProvider(new Uri("http://localhost:7077/api/serviceprovider"));

            HttpResponseMessage response =   _client.CreateResource("http://localhost:7077/api/reqtest/",
                    req, OslcMediaType.APPLICATION_RDF_XML);

Here is the OSLC-controller, on the post method code, on the provider side:
           title = "Requirement Creation Factory",
           label = "Requirement Creation",
           resourceShapes = new string[] {Constants.PATH_SWObject_REQUIREMENT + "?" + Constants.PATH_SWObject_REQUIREMENT_SHAPE },
           resourceTypes = new string[] { Constants.TYPE_SWObject_REQUIREMENT },
           usages = new string[] { OslcConstants.OSLC_USAGE_DEFAULT }
        public HttpResponseMessage PostRequirement(SWObject requirement)
            // Lazy create identifier, can fail if unlucky.
            Random rnd = new Random();
            int rand = rnd.Next(1000, 2000); // creates a number between 1 and 12

            requirement.SetIdentifier("req_" + rand);

            requirement.SetAbout(new Uri(ServiceProviderController.About.ToString() + "/" + requirement.GetIdentifier()));

            //Create a response containing the new resource + a Location header
            var response = Request.CreateResponse<SWObject>(HttpStatusCode.Created, requirement);
            string uri = Url.Link("DefaultApi", new { id = requirement.GetIdentifier() });
            response.Headers.Location = new Uri(uri);
            return response;
What have I missed or doing wrong?

Best Regards /Peter