New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is XML Based Response Supported #54
Comments
You need to use custom response serializer for that, by default TRON assumes you are using JSON or key-value based payloads. For examples on how to implement that you can take a look at Response serializers doc. |
What if I want the response to just be in strings. Do, I still have to write a serializer? Because, I've tried something like this and still no response
|
Yes, because by default SwiftyJSON is used and it will try to initialize JSON object from your String. |
Okay. So, I did this:
Utilizing the Serializer below:
But, data is empty always. Am I still doing anything wrong? |
Looks fine, apart from bunch of force unwraps. It probably should work, can you post your code for using this response serializer? |
Updated @DenHeadless |
I don't understand what following part does:
But other than that looks fine. You can also try this request using cURL and see if it works correctly. You can get curl for final request by doing something like this: let sentRequest = request.perform(withSuccess: { _ in }, error: { _ in})
debugPrint(sentRequest) // This line will get you resulting cURL. |
Everything is working fine. For anyone looking at implementing XML this is the full workaround:
And, in your request, remember to add the "Accept" header to accept "text/xml" or and "application/xml"
|
I've been trying to utilize TRON for an API that gives response in
XML
and my response has been empty always. This is how I've been making my requests:Am I doing anything wrong? Thanks.
The text was updated successfully, but these errors were encountered: