simple-odata-client / Simple.OData.Client

MIT License
331 stars 197 forks source link

MIME type error when try to call function #492

Open sanphir opened 6 years ago

sanphir commented 6 years ago

I've got "The MIME type 'application/json; odata.metadata=minimal,IEEE754Compatible=true' requires a '/' character between type and subtype, such as 'text/plain'." After trying to get data from function call var client = GetOdataClient(); var result = await client.Unbound<IEnumerable<WorkPlaceDTO>>() .Function("Get") .Set(new { terminalCode = _terminalNumberProvider.TerminalNumber }) .ExecuteAsSingleAsync();

object commented 6 years ago

How is "Get" function defined in the schema? Can you send me a schema document?

sanphir commented 6 years ago

We user Restire for server side API. I successfully get it with simple http request from code or from postman. But simple.odata client raise MIME type exception. ` namespace MES.MesServices { public class WorkPlacesApi : MesApiBase { public WorkPlacesApi(IServiceProvider serviceProvider) : base(serviceProvider) { }

    [Operation]
    public OdataMethodResponse Get(string terminalCode)
    {
        return this.GetResponse(() =>
        {
            var service = ServiceResolver.GetAll<IWorkPlaceService>().FirstOrDefault();
            return service?.GetWorkPlaces(terminalCode) ?? new WorkPlaceDTO[0];
        });
    }

    public new static IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
    {
        var typeProvider = ServiceResolver.GetAll<IWorkPlaceService>().FirstOrDefault() as IEntityTypeProvider;
        var types = typeProvider?.GetTypes() ?? Type.EmptyTypes;
        services.AddService<IModelBuilder>((sp, next) => new DtoModelBuilder(types.ToArray()));

        var result = ApiBase.ConfigureApi(apiType, services);
        return result;
    }
}

}`

object commented 6 years ago

Thanks, it will simplify things a lot for me if I can get a service schema (available at /$metadata).