question

bodin avatar image
bodin asked

httpRequestError in Cloudscript

Hi,

I'm testing http request function.

even though it's working fine on PHP side (POST data had been received & run correctly)

I got error on Playfab side with the error log below.

"result": {
   "responseContent": null,
   "httpStatus": null,
   "httpStatusCode": 0,
   "requestError": "InternalError"
}

I checked old topic, and try remove the header, but the solution didn't work for me.

https://community.playfab.com/questions/5744/when-i-try-https-request-i-got-cloudscripthttprequ.html

https://community.playfab.com/questions/4408/error-in-cloudscript-http-request-says-see-the-err.html

here is my code.

handlers.TestHTTPRequest = function (args, context) {
    var headers = {};
    
    var body = {
        name: "NAME DATA",
	address: "90/147 soi songsaafg"
    };


    var url = "http://xxxxxxxx.net/sendemailpost.php";
    var content = JSON.stringify(body);
    var httpMethod = "post";
    var contentType = "application/json";


    // The pre-defined http object makes synchronous HTTP requests
    var response = http.request(url, httpMethod, content, contentType, headers);
    return { responseContent: response };
};

Could you please help let me know if I did something wrong?

Best regards,

Bodin

CloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Looking at our logs, the issue is that your http.request() call is timing out. Calls to external Web API endpoints time out if we don't hear back within 2.5 seconds - if you look at the error logs, you'll see that each of the two failures you had in testing recently both had runtimes of a bit more than 2.6 seconds, which is a good indication of this. I'd recommend either a) switching to a provider with higher levels of availability, or b) getting set up with an SMTP provider and using our integrated mail feature (which you can find in the Add-ons tab).

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bodin avatar image bodin commented ·

Hi @Brendan,

Thank you very much for your reply.

for your second solution "integrated mail feature" can I insert my custom data that I can change via script, into the email body?


I once tested it and I can't find the way to insert custom data except play profile via $Profile.XXXXX$

if there any way to do this, Could you please let me know?

0 Likes 0 ·
brendan avatar image brendan bodin commented ·

As far as we're concerned, the body of the email is an arbitrary string. However, that string data is set in the template you configure in your title. So if the question is, can you change the specific details of the email data being sent out via input parameters to the API call, then no, I'm afraid that's not supported.

1 Like 1 ·
bodin avatar image bodin brendan commented ·

Thank you for your clarification. so the integrated mail system is not the option.

I think it took more time to wait for the sending email process to finish. may be I try another provider.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.