The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

I am trying to make an API call to an API which returns an XML document as the response. This request works fine in post man and with other languages but I am not sure how to get the XML file in godot. When I make the request it just returns 0 as the response and a bunch of comma separated numbers as the body which is confusing because I didn't get that response on postman. Here is the code I am using to make the request.

func _on_LineEdit_text_entered(new_text):
$HTTPRequest.request("http://export.arxiv.org/api/query?search_query=all:electron&start=0&max_results=1")


func _on_HTTPRequest_request_completed(result, response_code, headers, body):
    print(result)

This Code works when making calls to APIs that return json values but im not sure how to get it working with an API that returns an XML

Godot version 3.5
in Engine by (23 points)

1 Answer

+1 vote
Best answer

A result of 0 means success. It sounds like it's working, you just need to convert body (probably a PoolByteArray) to a string.

by (1,055 points)
selected by

Ah that makes sense thank you, I hadnt heard of PoolByteArrays before. Do you know a way to convert it to a readable string or a link to a resource which might help me convert it?

var s = body.getstringfrom_utf8()

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.