SaaS CMS has officially launched! Learn more now.

Updating an Object in Find Index


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 ?

Aug 19, 2015 9:51

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

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

catch (Exception ex)

Aug 19, 2015 12:59

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

Edited, Aug 19, 2015 13:22

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

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.