Newer Version Available
Compression Headers
REST API supports the gzip and deflate compression algorithms, as defined by the HTTP 1.1 specification. If you’re unsure about which one to use, gzip is more common than deflate.
Request Compression
Include a Content-Encoding: gzip or Content-Encoding: deflate header to compress a request. REST API decompresses any requests before processing.
This example request is compressed with gzip.
1curl https://MyDomainName.my.salesforce.com/services/data/v62.0/sobjects/Account/ -H "Authorization: Bearer access-token" -H "Content-Type: application/json" -H "Content-Encoding: gzip" —data-binary @new-account.json -X POSTResponse Compression
Salesforce compresses a response only if the request contains an Accept-Encoding: gzip or Accept-Encoding: deflate header. REST API isn’t required to compress the response even if you’ve specified Accept-Encoding, but it normally does. If compressed, the response contains a Content-Encoding header with the compression algorithm so that your client knows to decompress it.
This example request asks for a compressed response.
1curl https://MyDomainName.my.salesforce.com/services/data/v62.0/sobjects/Account/0015e000009sS0DAAU -H "Authorization: Bearer access-token" -H "Content-Type: application/json" -H "Accept-Encoding: gzip" -X GET