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

input is null during POST #2686


User avatar
0
codenewa created

Hello,

I created my first service without any hiccups. But when working on the second service, I'm getting issues with the POST methods. Service Method:

[AbpAuthorize(AppPermissions.Pages_Administration_Tenant_AttributeSettings)]
    public class AttributesAppService : MMSAppServiceBase, IAttributesAppService
    {
...
[AbpAuthorize(AppPermissions.Pages_Administration_Tenant_AttributeSettings_Create_Update)]
        public async Task SaveAttributeSettings(SaveAttributeSettingInput input)
        {
            var attributeValue = input.MapTo<Attribute>();
            attributeValue.TenantId = AbpSession.TenantId;
            if (input.Id == 0)
...

Service-proxies.ts

/**
     * @return Success
     */
    saveAttributeSettings(input: SaveAttributeSettingInput): Observable<void> {
        let url_ = this.baseUrl + "/api/services/app/Attributes/SaveAttributeSettings";

        const content_ = JSON.stringify(input ? input.toJS() : null);
        
        return this.http.request(url_, {
            body: content_,
            method: "post",
            headers: new Headers({
                "Content-Type": "application/json; charset=UTF-8", 
				"Accept": "application/json; charset=UTF-8"
            })
        }).map((response) => {
...

component.ts

...
   save(): void {
        this.saving = true;
        this._svc.saveAttributeSettings(**this.attr**)
            .finally(() => this.saving = false)
            .subscribe(() => {
                this.notify.info('Saved Successfully');
                this.close();
                this.modalSave.emit(this.attr);
            });
    }
...

But when it runs it gives me the following error:

{result: null, targetUrl: null, success: false,…}
__abp
:
true
error
:
{code: 0, message: "Your request is not valid!",…}
code
:
0
details
:
"The following errors were detected during validation.
↵ - input is null!
↵"
message
:
"Your request is not valid!"
validationErrors
:
[{message: "input is null!", members: ["input"]}]
0
:
{message: "input is null!", members: ["input"]}
members
:
["input"]
message
:
"input is null!"
result
:
null
success
:
false
targetUrl
:
null
unAuthorizedRequest
:
false

Thank you for your help.


2 Answer(s)
  • User Avatar
    0
    codenewa created

    Turns out my input object was not well formed. It had missing properties which was causing the error. It's fixed now. Sorry about this.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Thanks for sharing your solution :)