Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Request is invalid when trigering service #1000


User avatar
0
feliw created

Hi,

I try to figure this error, but seems everything is okay but I receive "Your request is invalid", I already check the request payload and my JSON string seems okay, same as my DTO. Can advice me where I did wrong ?

The JSON seems cannot be serialize to CreateShiftDto so it return me "input is null"

Thanks before

Here is my piece of code

Service

public bool Create(CreateShiftDto input)
        {
            try
            {
                _shiftRepository.Insert(input.MapTo<Shift>());
                return true;
            }
            catch (Exception ex)
            {
                Logger.Debug(ex.Message);
                throw ex;
            }
        }

Angular function

function create() {
                shiftsService.create(vm.shiftss).success(function (result) {
                    abp.notify.success("Data is created!");
                    back();
                }).error(function (result) {
                    abp.notify.error(result);
                });
            }

this is my object (vm.shiftss)

"[{"seq":5,"code":"5","description":"555","timeStart":"2016-04-12T09:53:36.607Z","timeEnd":"2016-04-12T09:53:36.607Z"}]"

and this is my DTO

[AutoMap(typeof(Shift))]
    public class CreateShiftDto : IInputDto
    {
        public virtual int Seq { get; set; }
        public virtual string Code { get; set; }
        public virtual string Description { get; set; }
        public virtual DateTime TimeStart { get; set; }
        public virtual DateTime TimeEnd { get; set; }
    }

2 Answer(s)
  • User Avatar
    0
    paddyfink created

    your object vm.shiftss is a list but your your service expect an object.

    You need to pass an object. For example : shiftsService.create(vm.shiftss[0])

  • User Avatar
    0
    feliw created

    Hai Paddyfink,

    Thanks for your fast response. I see it's my fault. Have a nice day :D