0

I'm trying to deploy an Apex Class using Postman and the /metadata/deployRequest API. I get a 201 response, but when I check the deployment status, I see the error "No package.xml found".

Here's the complete body of my request including the base 64 zip. When I save the zip as a file and upload it using Workbench, it deploys.

----------------------------BOUNDARY
Content-Disposition: form-data; name="json"
Content-Type: application/json

{ 
    "deployOptions" : {
        "allowMissingFiles" : false,
        "autoUpdatePackage" : false,
        "checkOnly" : false,
        "ignoreWarnings" : false,
        "performRetrieve" : false,
        "purgeOnDelete" : false,
        "rollbackOnError" : false,
        "runTests" : null,
        "singlePackage" : true,
        "testLevel" : "RunAllTestsInOrg"
    }
}
----------------------------BOUNDARY
Content-Disposition: form-data; name="file"; filename="deploy.zip"
Content-Type: application/zip

UEsDBAoAAAAAANlihVbc+9DtwgAAAMIAAAALAAAAcGFja2FnZS54bWw8P3htbCB2ZXJzaW9uPSIxLjAiIGVuY29kaW5nPSJVVEYtOCI/PjxQYWNrYWdlIHhtbG5zPSJodHRwOi8vc29hcC5zZm9yY2UuY29tLzIwMDYvMDQvbWV0YWRhdGEiPjx0eXBlcz48bWVtYmVycz5IZWxsb1dvcmxkPC9tZW1iZXJzPjxuYW1lPkFwZXhDbGFzczwvbmFtZT48L3R5cGVzPjx2ZXJzaW9uPjU2LjA8L3ZlcnNpb24+PC9QYWNrYWdlPlBLAwQKAAAAAADZYoVWg7ZBRjoAAAA6AAAAFgAAAGNsYXNzZXMvSGVsbG9Xb3JsZC5jbHNwdWJsaWMgY2xhc3MgSGVsbG9Xb3JsZHtwdWJsaWMgc3RhdGljIHZvaWQgaGVsbG9Xb3JsZCgpe319UEsDBAoAAAAAANlihVZnWwVkoQAAAKEAAAAfAAAAY2xhc3Nlcy9IZWxsb1dvcmxkLmNscy1tZXRhLnhtbDw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9IlVURi04Ij8+PEFwZXhDbGFzcyB4bWxucz0iaHR0cDovL3NvYXAuc2ZvcmNlLmNvbS8yMDA2LzA0L21ldGFkYXRhIj48YXBpVmVyc2lvbj41Ni4wPC9hcGlWZXJzaW9uPjxzdGF0dXM+QWN0aXZlPC9zdGF0dXM+PC9BcGV4Q2xhc3M+UEsBAgoACgAAAAAA2WKFVtz70O3CAAAAwgAAAAsAAAAAAAAAAAAAAKSBAAAAAHBhY2thZ2UueG1sUEsBAgoACgAAAAAA2WKFVoO2QUY6AAAAOgAAABYAAAAAAAAAAAAAAKSB6wAAAGNsYXNzZXMvSGVsbG9Xb3JsZC5jbHNQSwECCgAKAAAAAADZYoVWZ1sFZKEAAAChAAAAHwAAAAAAAAAAAAAApIFZAQAAY2xhc3Nlcy9IZWxsb1dvcmxkLmNscy1tZXRhLnhtbFBLBQYAAAAAAwADAMoAAAA3AgAAAAA=
----------------------------BOUNDARY--

1 Answer 1

0

The physical data needs to be binary, not base64. In Postman, you can generate the body by using the form-data body type, and selecting the file to upload. See this answer on stack overflow.

5
  • Thanks, I found that post, but I wasn't sure how to upload the JSON section separately from the zip. I saved the deployment options as a JSON file, selected it on one line, then selected the zip file on a second line. I get a 500 with the message "An unexpected error occurred. Please include this ErrorId if you contact support: 1413132269-140266 (1602089773)" Commented Apr 6, 2023 at 16:08
  • But before we go to far debugging this, I ultimately just want to implement this in Apex and was just using Postman to understand the API. Do you know of any resources instructing how to do this specifically with this API? Commented Apr 6, 2023 at 16:11
  • @BrandonDeMatteis Apex makes it hard, because we don't have native binary support. Most people use EncodingUtil base64Encode/base64Decode or convertToHex/convertFromHex to build the proper payload.
    – sfdcfox
    Commented Apr 6, 2023 at 16:55
  • @BrandonDeMatteis Try this Q&A.
    – sfdcfox
    Commented Apr 6, 2023 at 16:57
  • Thanks for your help with this. I did get this working in the end using this solution: github.com/nicolas1bruno/multipart-data-apex-request Commented Apr 28, 2023 at 14:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .