0

Please check my code:

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://portal.ebs-next.com/ebsrentalinspectiontest/servicelayer/ebsrentalcheckinservicelayer.asmx/SetRentalCheckInImages",baseUrl]];

//////NSLog(@"URL:%@",url);

__block  ASIFormDataRequest *requestmethod = [ASIFormDataRequest requestWithURL:url];


NSUserDefaults *loginCheck=[NSUserDefaults standardUserDefaults];



NSString *loginValidation=[loginCheck valueForKey:@"USER_ID"];

UIImage *img = [UIImage imageNamed:@"overlaygraphic.png"];


NSData *imageData = UIImageJPEGRepresentation(img, 1.0);

NSString *encodedString = [imageData base64Encoding];




[requestmethod setValidatesSecureCertificate:NO];
[requestmethod setPostValue:@"196" forKey:@"checkindetlid"];

 [requestmethod setPostValue:encodedString forKey:@"imgpath"];


[requestmethod setPostValue:@"" forKey:@"description"];
[requestmethod setPostValue:@"0"  forKey:@"id"];

[requestmethod setPostValue:@"" forKey:@"content"];
[requestmethod setPostValue:@"0" forKey:@"offset"];

[requestmethod setPostValue:@"mRHcXXatqUayMNyP8nlEmA==" forKey:@"usrToken"];
[requestmethod setPostValue:@"KLB050572RC" forKey:@"equipmentid"];


//[requestmethod setPostFormat:ASIMultipartFormDataPostFormat];

[requestmethod setTimeOutSeconds:500];




[requestmethod setCompletionBlock:^{
    NSString *responseString23 = [requestmethod responseString];


    NSLog(@"Image Response:%@",responseString23);




}];
[requestmethod setFailedBlock:^{




    NSError *error = [requestmethod error];

    NSLog(@"%@",error.localizedDescription);






}];

[requestmethod startAsynchronous];

My need is :

  1. Convert UIImage to Base64 String - Its completed

  2. Post this values to server. But server always displays null value. Instead of post base64 string to any other string Its worked correctly.

    [requestmethod setPostValue:[NSString stringWithFormat:@"%@",encodedString] forKey:@"imgpath"];
    
PREMKUMAR
  • 8,283
  • 8
  • 28
  • 51
  • Use AFNetworking for your requirement – Paresh Navadiya Mar 06 '15 at 10:07
  • Yes i tried AFnetwroking its also display same error. My issue is how to post base64 string to webserver. – PREMKUMAR Mar 06 '15 at 10:12
  • If you send @"randomString" for the key `@"imgpath"`, does the server get it? Plus why do you do `stringWithFormat:` if `encodedString` is already a `NSString`? – Larme Mar 06 '15 at 10:16
  • Yes correct.random string is worked fine – PREMKUMAR Mar 06 '15 at 10:17
  • Could your server limit the size of the string? Maybe if you try with smaller image (and then smaller `encodedString`)? – Larme Mar 06 '15 at 10:21
  • http://portal.ebs-next.com/ebsrentalinspectiontest/servicelayer/ebsrentalcheckinservicelayer.asmx?op=SetRentalCheckInImages @Larme This is my web service page here also same think happening. – PREMKUMAR Mar 06 '15 at 10:23
  • If you try with another solution of base encoding 64 (I saw a few online solution) and try with your page, does it works? It could be some server issue. If it works, you may try to see if the two encoded strings are the same. – Larme Mar 06 '15 at 10:29
  • okay i will try. other encoding methods. – PREMKUMAR Mar 06 '15 at 10:32
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/72400/discussion-between-premkumar-and-larme). – PREMKUMAR Mar 06 '15 at 11:25

0 Answers0