Updating an Object in Find Index

Vote:
 

I'm using some what smiler to following code for update an object in Find Service

client.Update(Id).Field(x => x.PublishDate, newTime).Execute();

But when particulate object is not in the index, I'm getting following error:

[WebException: The remote server returned an error: (404) Not Found.]

But what I want is, if particular item is not available in the index, query should execute without an exception (even though it will not effecting any object in the index). So how could I achieve this ?

#132829
Aug 19, 2015 9:51
Vote:
 

You can put your code insida a try-catch-statement:

try
{
    client.Update<BlogPost>(Id).Field(x => x.PublishDate, newTime).Execute();

}
catch (Exception ex)
{

}
#132847
Aug 19, 2015 12:59
Vote:
 

 Johan, other than try-catch, is there any systematic EPiServer Find way (in query level) of doing this ?

#132849
Edited, Aug 19, 2015 13:22
Vote:
 

I don't think so. It's common practice to return 404 status codes in RESTful APIs when objects are not found.

#132850
Aug 19, 2015 13:25
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.