'API error: App Transport Security has blocked a cleartext HTTP connection to example.com since it is insecure

While requesting POST API, It gives me:

App Transport Security has blocked a cleartext HTTP connection to example.com since it is insecure. Use HTTPS instead or add this domain to Exception Domains in your Info.plist.

enter image description here

By adding below code info.plist works and error is not coming but now it is not passing anything in header (Authorization token).

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
      <true/>
</dict>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source