JsonApiClient 204 status code

A little bit of context:

From typescript, using code:

const api = await client.api(
    new CellProgressUpdate({
      Id: // the id
      ProgressPercent: // the progress
  if (api.succeeded) {
    $q.notify('Progress updated')    
  } else {
    console.log(api) // log here to check -- succeeded: false, completed:false
    $q.notify('Error: ' + api.errorMessage)

My service doesn’t return a value:

public async Task Post(CellProgressUpdate req)
    var cell = await repo.Load(req.Id);
    if (cell == null)
        throw HttpError.NotFound("Cell not found");
    cell.Progress = (float)(req.ProgressPercent) / 100;

    await repo.SaveCell(cell);

Network log shows the service returns 204 No content, as it is void. The DTO is marked with IReturnVoid:

    public class CellProgressUpdate : IReturnVoid
        public ID Id { get; set; }
        public int ProgressPercent { get; set; }

And this is also visible in the dtos.ts:

export class CellProgressUpdate implements IReturnVoid

So what’s the problem? I’ve done step-by-step debugging, and there’s no exceptions.

The code return successfully, with 204 No Content, as I guess IReturnVoid should do, but when I log the api object, succeeded is false, completed is false.

Is there something with the JsonApiClient that needs a response to work? I could add a dummy object, or return the updated object, just curious as to why the JsonApiClient interprets this as a incomplete/failed response.

The servicestack-client has api and apivoid methods to distinguish between these since the api method has a typed TResponse which you won’t have for an IReturnVoid Request DTO.

I’ll update the typescript client docs page to more clearly list these method options.

1 Like

Thank you, and for a very quick reply as always.