Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: bad request (400)

前端 未结 3 1751
春和景丽
春和景丽 2021-01-12 17:54

I am using AFnetworking library to post data on server.

Following is my code to post data on server.

- (void) callLoginAPI:(NSDictionary *)dictProfil         


        
相关标签:
3条回答
  • 2021-01-12 18:09

    The error says it all: you got a 400 response from the server, meaning that what you sent was either not formatted properly, or the server just couldn't understand it.

    0 讨论(0)
  • 2021-01-12 18:11

    Please add this line to your code, i hope it help you.

    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
    
    0 讨论(0)
  • 2021-01-12 18:18

    I had experienced the same issue. In my case its only for upload Image with larger size. Our server has limited with max.upload size. I resized the image and uploaded, and the issue is gone.

    You can resize the image with:

    + (UIImage*)imageWithImage:(UIImage*)image
                  scaledToSize:(CGSize)newSize;
    {
        UIGraphicsBeginImageContext( newSize );
        [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
        UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    
        return newImage;
    }
    
    0 讨论(0)
提交回复
热议问题