I have 2 projects one for user and the other one for provider.
I use the same code and sam api for an activity, and it works fine in provider but it does not work for user!!
I used this code
AFHTTPSessionManager *manager=[AFHTTPSessionManager manager];
NSString *strURL=[NSString stringWithFormat:@"%@%@",SERVICE_URL,path];
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
but the error is:
Error Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: forbidden (403)" UserInfo={NSLocalizedDescription=Request failed: forbidden (403), NSUnderlyingError=0x600002a08ba0 {Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo={NSLocalizedDescription=Request failed: unacceptable content-type: text/html, NSErrorFailingURLKey=https://api.com, com.alamofire.serialization.response.error.data={length = 3273, bytes = 0x3c21444f 43545950 45206874 6d6c3e0a ... 3c2f6874 6d6c3e0a }, com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x6000024d0b80> { URL: https://api.com } { Status Code: 403, Headers {
"Cache-Control" = (
"private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
);
"Content-Encoding" = (
br
);
"Content-Type" = (
"text/html; charset=UTF-8"
);
Date = (
"Thu, 25 Feb 2021 07:26:49 GMT"
);
Expires = (
"Thu, 01 Jan 1970 00:00:01 GMT"
);
I added this line in the code:
manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
but this error appears:
JSON text did not start with array or object and option to allow fragments not set.
then, i added this code:
manager.responseSerializer = [AFJSONResponseSerializer
serializerWithReadingOptions:NSJSONReadingAllowFragments];
and it gave me the same issue for accepting text/html !!!
give me a solution please.
thank you in advance.