sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve
asked on 17 Oct 2011, 04:28 AM
How do I call an odata method?
This is what I need to call
Works though fiddler, however the kendo DS is appending these $format=json&$inlinecount=allpages&$callback=callback which is throwing a error 400 bad request.
Looks like if I remove this parameter fiddler, it returns the proper value
"$inlinecount=allpages"
How can I prevent that from being passed?
This is what I need to call
http:
//odata.site.com/USDA.svc/GetNutritionalInfo?ndbno=1001&seq=107&servingsize=1
Works though fiddler, however the kendo DS is appending these $format=json&$inlinecount=allpages&$callback=callback which is throwing a error 400 bad request.
Looks like if I remove this parameter fiddler, it returns the proper value
"$inlinecount=allpages"
How can I prevent that from being passed?
10 Answers, 1 is accepted
0
Hello Steve,
Also you may enable the verbose errors to see more detail description of the error you are getting.All the best,
Rosen
the Telerik team
Could you please verify that the OData service is V2 compatible. For example if you are using WCF DataService the following line does exists in the InitializeService:
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
Also you may enable the verbose errors to see more detail description of the error you are getting.All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 17 Oct 2011, 02:25 PM
Ok, I'll enable Verbose...I am running V2 though
So even calling "TestMethod" fails with the KendoDS...and it does nothing but return true
using
System;
using
System.Collections.Generic;
using
System.Data.Objects;
using
System.Data.Services;
using
System.Data.Services.Common;
using
System.Linq;
using
System.ServiceModel.Web;
using
System.Web;
using
DataServicesJSONP;
namespace
My.oData
{
[JSONPSupportBehavior]
public
class
USDA : DataService<MyEntities>
{
// This method is called only once to initialize service-wide policies.
public
static
void
InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule(
"*"
, EntitySetRights.AllRead);
//Set a reasonable paging site
config.SetEntitySetPageSize(
"*"
, 25);
config.SetServiceOperationAccessRule(
"GetNutritionalInfo"
, ServiceOperationRights.AllRead);
config.SetServiceOperationAccessRule(
"TestMethod"
, ServiceOperationRights.All);
//config.UseVerboseErrors = true;
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
protected
override
void
OnStartProcessingRequest(ProcessRequestArgs args)
{
base
.OnStartProcessingRequest(args);
HttpCachePolicy c = HttpContext.Current.Response.Cache;
c.SetCacheability(HttpCacheability.ServerAndPrivate);
c.SetExpires(HttpContext.Current.Timestamp.AddSeconds(60));
c.VaryByHeaders[
"Accept"
] =
true
;
c.VaryByHeaders[
"Accept-Charset"
] =
true
;
c.VaryByHeaders[
"Accept-Encoding"
] =
true
;
c.VaryByParams[
"*"
] =
true
;
}
[WebInvoke(Method =
"POST"
)]
[WebGet]
public
getFoodNutritionalInfo_Result GetNutritionalInfo(
int
ndbno,
double
servingsize,
int
seq)
{
MyEntities entities =
new
MyEntities
();
ObjectResult<getFoodNutritionalInfo_Result> result = entities.getFoodNutritionalInfo(ndbno, servingsize, seq);
return
result.FirstOrDefault();
}
[WebInvoke(Method =
"POST"
)]
[WebGet]
public
bool
TestMethod()
{
return
true
;
}
}
}
So even calling "TestMethod" fails with the KendoDS...and it does nothing but return true
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 18 Oct 2011, 04:15 AM
This is the Verbose error
...so how do I stop the DS applying it?
callback({
"error"
: {
"code"
:
""
,
"message"
: {
"lang"
:
"en-US"
,
"value"
:
"Query options $expand, $filter, $orderby, $inlinecount, $skip and $top cannot be applied to the requested resource."
}
}
})
...so how do I stop the DS applying it?
0
Hello Steve,
Rosen
the Telerik team
The error you are getting is cause by the fact that the parameters are applicable only for methods which return IEnumerable. However, your method returns a plaint type instead, which also is not valid binding for our DataSource too. The DataSource expects some kind of array to be received from the server.
All the best,Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 18 Oct 2011, 01:13 PM
Changing it to ObjectResult<> or IEnumerable<> directly yields the exact same error
[WebInvoke(Method =
"POST"
)]
[WebGet]
public
IEnumerable<getFoodNutritionalInfo_Result> GetNutritionalInfo(
int
ndbno,
double
servingsize,
int
seq)
{
GourmetSleuthEntities entities =
new
GourmetSleuthEntities();
ObjectResult<getFoodNutritionalInfo_Result> result = entities.getFoodNutritionalInfo(ndbno, servingsize, seq);
return
result;
}
[WebInvoke(Method =
"POST"
)]
[WebGet]
public
ObjectResult<getFoodNutritionalInfo_Result> GetNutritionalInfo(
int
ndbno,
double
servingsize,
int
seq)
{
GourmetSleuthEntities entities =
new
GourmetSleuthEntities();
ObjectResult<getFoodNutritionalInfo_Result> result = entities.getFoodNutritionalInfo(ndbno, servingsize, seq);
return
result;
}
0
Hi Steve,
Rosen
the Telerik team
Unfortunately, I'm unable to recreate the behavior locally, therefore could you please provide a small sample in which this can be observed locally.
All the best,Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Grace
Top achievements
Rank 1
answered on 13 Jan 2012, 07:36 PM
Hi Steve,
Did you resolve this issue? I'm getting the same behavior and looking for a resolution. Thanks!
Did you resolve this issue? I'm getting the same behavior and looking for a resolution. Thanks!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 13 Jan 2012, 07:38 PM
Yes, I think in another forum thread, when I get home I'll post the snippit, but I think off the top of my head I just didn't use oData as the type but instead jsonp
0
Grace
Top achievements
Rank 1
answered on 14 Jan 2012, 01:44 AM
Oh thank you! That'd be wonderful.
0
Courouble Damien
Top achievements
Rank 1
answered on 17 May 2012, 11:41 AM
Would like to give us your code ? I'm facing similar issue here !
Thanks
Thanks