1

How to print HTTPBody using alamofire multipart request Swift

Right now I am trying with below code but app crash on this line

print("HTTP Body \(String(data: (response.request?.httpBody)!, encoding: .utf8) ?? "HTTP body not found")")

I am using multipart request

I want to print like this HTTPBody

// HTTP body: foo=bar&baz[]=a&baz[]=1&qux[x]=1&qux[y]=2&qux[z]=3
Vivek
  • 4,916
  • 35
  • 40

1 Answers1

0

Use this code

print(String(decoding: response.request?.httpBody ?? Data(), as: UTF8.self))
Awais Khan
  • 116
  • 9
  • Thank you for your answer this code is not working with a multipart request, I want to print HTTP body for a multipart request. – Vivek Jul 16 '19 at 05:36