unable to post data through OData proxy

Mar 11, 2011 at 8:52 AM

 

 

I am working on iPad application. I am consuming WCF data service and I am trying to add a new record in the SQL server db using the proxy object. 

I am getting Http 403 error. My application gets crashed when error occured. 

I am using below code: 

DemoService *proxy=[[DemoService alloc]initWithUri:@"http://services.odata.org/(S(qg3ip020t4o00tpd1wbrb2l4))/OData/OData.svc/" credential:nil];
        
        ODataDemo_Product *p = [[ODataDemo_Product alloc] init];
        NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
        [fmt setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSS'Z'"];
        
        NSDate *d = [fmt dateFromString:@"2011-01-22T00:00:20.20"];
        
        [p setID:[NSNumber numberWithInt:5003]];
        [p setName:@"product_january_5003"];
        [p setDescription:@"product information:This is demo product information:5002"];
        [p setReleaseDate:[NSDate date]];
        [p setRating:[NSNumber numberWithInt:5]];
        [p setDiscontinuedDate:d];
        //[p setPrice:[NSDecimalNumber numberWithInt:1200]];
        
        [proxy addToProducts:p];
        [proxy saveChanges];

 

can anyone suggest me?

Mar 11, 2011 at 6:13 PM

The code you have is from the sample program where RootViewController.m has a method called addProductObject. That should work in Version 1.1.  I can't tell why it's crashing for you. Can you post also the console output from your XCode debug session?

I did try the same thing using Version 1.2 (not released yet, but soon will be), and it worked. Below is the console output:

[Session started at 2011-03-11 11:01:58 -0800.]

2011-03-11 11:02:16.451 ODataSampleApp[5283:207] class...ODataDemo.Product

2011-03-11 11:02:16.454 ODataSampleApp[5283:207] HTTP URL = http://services.odata.org/(S(4pso0zvr1z0vxiozq2sudgcs))/OData/OData.svc/Products

2011-03-11 11:02:17.030 ODataSampleApp[5283:207] status code : HTTP status code 201

2011-03-11 11:02:17.032 ODataSampleApp[5283:207] Data = <?xml version="1.0" encoding="utf-8" standalone="yes"?>

<entry xml:base="http://services.odata.org/(S(4pso0zvr1z0vxiozq2sudgcs))/OData/OData.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">

<id>http://services.odata.org/(S(4pso0zvr1z0vxiozq2sudgcs))/OData/OData.svc/Products(5057)</id>

<title type="text">7Feb_product</title>

<summary type="text">product information:This is demo product information:5057</summary>

<updated>2011-03-11T19:01:49Z</updated>

<author>

   <name />

</author>

<link rel="edit" title="Product" href="Products(5057)" />

<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Category" type="application/atom+xml;type=entry" title="Category" href="Products(5057)/Category" />

<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier" type="application/atom+xml;type=entry" title="Supplier" href="Products(5057)/Supplier" />

<category term="ODataDemo.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />

<content type="application/xml">

   <m:properties>

     <d:ID m:type="Edm.Int32">5057</d:ID>

     <d:ReleaseDate m:type="Edm.DateTime">2011-03-11T11:02:16Z</d:ReleaseDate>

     <d:DiscontinuedDate m:type="Edm.DateTime">2011-02-03T00:00:20Z</d:DiscontinuedDate>

     <d:Rating m:type="Edm.Int32">5</d:Rating>

     <d:Price m:type="Edm.Decimal" m:null="true" />

   </m:properties>

</content>

</entry>

2011-03-11 11:02:17.113 ODataSampleApp[5283:207] ele...link

2011-03-11 11:02:17.120 ODataSampleApp[5283:207] name...id

2011-03-11 11:02:17.121 ODataSampleApp[5283:207] name...title

2011-03-11 11:02:17.122 ODataSampleApp[5283:207] name...summary

2011-03-11 11:02:17.122 ODataSampleApp[5283:207] name...updated

2011-03-11 11:02:17.123 ODataSampleApp[5283:207] name...author

2011-03-11 11:02:17.124 ODataSampleApp[5283:207] name...link

2011-03-11 11:02:17.124 ODataSampleApp[5283:207] name...link

2011-03-11 11:02:17.125 ODataSampleApp[5283:207] name...link

2011-03-11 11:02:17.126 ODataSampleApp[5283:207] name...category

2011-03-11 11:02:17.127 ODataSampleApp[5283:207] name...content

2011-03-11 11:02:17.127 ODataSampleApp[5283:207] ele...title

2011-03-11 11:02:17.128 ODataSampleApp[5283:207] name...id

2011-03-11 11:02:17.129 ODataSampleApp[5283:207] name...title

2011-03-11 11:02:17.130 ODataSampleApp[5283:207] name...summary

2011-03-11 11:02:17.130 ODataSampleApp[5283:207] name...updated

2011-03-11 11:02:17.131 ODataSampleApp[5283:207] name...author

2011-03-11 11:02:17.132 ODataSampleApp[5283:207] name...link

2011-03-11 11:02:17.132 ODataSampleApp[5283:207] name...link

2011-03-11 11:02:17.133 ODataSampleApp[5283:207] name...link

2011-03-11 11:02:17.134 ODataSampleApp[5283:207] name...category

2011-03-11 11:02:17.135 ODataSampleApp[5283:207] name...content

2011-03-11 11:02:17.135 ODataSampleApp[5283:207] ele...summary

2011-03-11 11:02:17.136 ODataSampleApp[5283:207] name...id

2011-03-11 11:02:17.137 ODataSampleApp[5283:207] name...title

2011-03-11 11:02:17.138 ODataSampleApp[5283:207] name...summary

2011-03-11 11:02:17.138 ODataSampleApp[5283:207] name...updated

2011-03-11 11:02:17.139 ODataSampleApp[5283:207] name...author

2011-03-11 11:02:17.140 ODataSampleApp[5283:207] name...link

2011-03-11 11:02:17.140 ODataSampleApp[5283:207] name...link

2011-03-11 11:02:17.141 ODataSampleApp[5283:207] name...link

2011-03-11 11:02:17.142 ODataSampleApp[5283:207] name...category

2011-03-11 11:02:17.142 ODataSampleApp[5283:207] name...content

2011-03-11 11:02:17.143 ODataSampleApp[5283:207] ele...content

2011-03-11 11:02:17.144 ODataSampleApp[5283:207] name...id

2011-03-11 11:02:17.145 ODataSampleApp[5283:207] name...title

2011-03-11 11:02:17.145 ODataSampleApp[5283:207] name...summary

2011-03-11 11:02:17.146 ODataSampleApp[5283:207] name...updated

2011-03-11 11:02:17.147 ODataSampleApp[5283:207] name...author

2011-03-11 11:02:17.147 ODataSampleApp[5283:207] name...link

2011-03-11 11:02:17.148 ODataSampleApp[5283:207] name...link

2011-03-11 11:02:17.149 ODataSampleApp[5283:207] name...link

2011-03-11 11:02:17.150 ODataSampleApp[5283:207] name...category

2011-03-11 11:02:17.150 ODataSampleApp[5283:207] name...content

Mar 15, 2011 at 11:28 AM

I am getting below error:

 

[Session started at 2011-03-15 16:26:54 +0530.]

[Session started at 2011-03-15 16:27:19 +0530.]

2011-03-15 16:27:23.398 Service[5869:207] HTTP URL = http://10.10.10.119/Service/DataService.svc/Records

2011-03-15 16:27:23.427 Service[5869:207] status code : HTTP error 403