我无法从API中获取数据。当API中没有图像数据字节时,它工作正常。但是使用图像参数键,我没有得到响应。我尝试过AFNetworking
,NSURLConnection
,HTTP
,但没有运气。它在Simulator上工作正常,但在真实设备上却没有。
API响应:
"Image": "/9j/4AAQSkZJRgABAQEAYABgAAD/4QBaRXhpZgAATU0AKgAAAAgABQMBAAUAAAABAAAASgMDAAEAAAABAAAAAFEQAAEAAAABAQAAAFERAAQAAAABAAAOw1ESAAQAAAABAAAOwwAAAAAAAYagAACxj//bAEMAAgEBAgEBAgICAgICAgIDBQMDAwMDBgQEAwUHBgcHBwYHBwgJCwkICAoIBwcKDQoKCwwMDAwHCQ4PDQwOCwwMDP/bAEMBAgICAwMDBgMDBgwIBwgMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/AP30+2oMY3YNAvkH9406KFTEm5CGCjPHtTvIT+6fyoAZ/aCehpjamAxAjcgegqVkiTGRjNIFBJC4wKLCcrEMmroi5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k+Of2X9G+G+j+H/DPh6a3tLjVZNQMk8sgWKfcUMXXD4+/2r2T/AINAdelk+JPx509gQCNIkhbjKBjqWf6V8a/8HBfwrl+HP/BWv4nyutytlr/2HUrKMlQGVbC1hdunI3q9KrTiqsZJa2QqNepNOg5O19r6HxlYrHbqot5mmjACrLjBkX1P1qW4iWOxZUUIGOSFGMn1oVS537VUNzhQQB9KlYF4imCM1SSuPl5dEUmQ7IuTxT54yzDqanMGVQZHyUN+8fABBouBV8QwhdAnIA4Rv5V/UL+wxeMP2Jvg6N7DHgjRe/8A04QV/MFr48zQbhACCyEZP0r+lT9ijxvFY/safCSBoZGaHwXo6EgjBxYwipn0A/nF8Q2ATxLrAwAP7Tuv/RzVG1kPNTAFS+LZGt/HviSNCVRdYvcD0/0h6zr2+mt7R5Ucq64weOOainP3UNlm4sh6VHaWQuLhVfhIiW/8drJ/4SW+PW4b/vlf8K2vD0zX0IuJTvmjJ2t0xxWsHzXREpctmfq5/wAGiQvrb9pn4tyrkWFzp+m59CwF9t/mas/8HcPwXbw9+0n8MPiDFEiW2oaM2jXbBMebKZZ5FJPchIwOfSvV/wDgzzsodR+FPxouJ40knOp2C7yMNjdfcV2X/B3/AKdA37E/w1uDEpmi8cRbX7j/AEC94qas7zXkiaa0dj8Ef7PRPlGMDikawBGBjNZ0WsXMsas0pLMMngVBqmuXdtbq0czKxbHQeho5xqfQ1/7Oakjshv6DIrDg8QXkg+adj+AqsPEV6ZSDcNgE9h60uYcpWOj12zC6NcHjIQ1/RB+x4xH7I/wsGenhDSf/AEihr+bfxBq1zJpTI0zFXK5Hr8wr98v2WvEt/B+zJ8OUS5kVE8L6YoHHAFpFSlK5PtD/2Q==",
"Name": "TEST NAME",
"ResponseMessage": "Success",
"no": 1
我尝试过各种各样的可能性,可能是我做错了什么。请指教。
谢谢!
答案 0 :(得分:1)
最后,我能够解决这个问题。由于来自服务器的响应包括文本以及UTF-8编码的图像数据的字节。因此,要获得响应,我们需要在标题字段中定义确切的内容类型,即
[request setValue:@"application/json;charset=UTF-8" forHTTPHeaderField:@"content-type"];
感谢大家的关注。