Bug in network.request (tested on Parse)

local function networkListener( event ) if ( event.isError ) then print( "error") else print ( "RESPONSE: " .. event.response ) end end local headers = {} headers["X-Parse-Application-Id"] = "my key here" headers["X-Parse-REST-API-Key"] = "my key2 here" headers["Content-Type"] = "application/json" local params = {} params.headers = headers network.request( "https://api.parse.com/1/config", "GET", networkListener, params )

Corona team, please try this code on some Windows Phone (using CoronaCards).

It will give you this:

A request with this method cannot have a request body.

And the event table looks like this:

table: 095D3C08 {

  [name] => “networkRequest”

  [isError] => true

  [bytesTransferred] => 0

  [phase] => “ended”

  [url] => "https://api.parse.com/1/config"

  [bytesEstimated] => 0

  [requestId] => userdata: 00000008

}

You don’t need to create an app on Parse, because I get the same error even if I do not provide the right keys. Obviously, the error triggers before it gets to Parse verification.

I have tried some network.request without custom headers and that works.

Hopefully, this is enough info to help you find the bug.

Corona Engineers can’t track bugs in the forums. You will need to find a bug report using the “Report a bug” link at the top of the page. Your bug report requires a complete, buildable project; that is a main.lua, build.settings, config.lua and any resources needed to build. Please provide the minimal code that demonstrates the problem.

Thanks

Rob

I am sure your Engineers have some Windows Phone projects ready.

All they need to do is paste this code in the main.lua and call it.

I have lost a enough time on this.

Thank you.

I’m sorry you feel this way. I don’t know what other suggestions I can offer you at this point. If you refuse to submit the bug report, there isn’t much our engineers can do.

Rob

Hi Rob,

thank you very much for trying to help.

But this is not a super complicated case. 

Is is a very simple REST call.

I am sure the Engineers will take a look if you whisper to them:

“Hey guys, seems we have a bug in REST call with GET and custom headers for Windows Phone” :wink:

We have to have a bug report. It’s happened so many times where we take your forum code and simply pop it in an existing test app and we can’t find the problem because there is something else causing the problem. If this bug is important to you, please take the time and file a bug report. We can’t guess at what’s going on. We have been burned by this too many times and end up wasting too much time trying to guess at your setup.

In fact, if it’s as simple as you say, consider the time we’ve been going back and forth about this. You could have filed the bug already and I could have an engineer looking at it already. Now you’re looking at next week at the earliest.

Rob

I think it’s an issue with your “content-type” header.  It doesn’t make any sense to add that to your headers table since a “GET” request never pushes any content (ie: there’s no body; you’re not pushing any JSON data) to the server.  Comment it out.

Perhaps you meant to set the “accept” header to “application/json”?

Also note that Corona will just blindly push all of your header info (except for content-length) into the HTTP request on all platforms.  It’s up to you set up the headers correctly.  In this case, this error message is coming from the WP8 operating system.  It’s telling you that “GET” request are not allowed to have content, but you specify a content-type in the header.  This is just Microsoft validating your configuration.

Hi Joshua, thank you for your help.

That was it!

When I removed the “content-type”, no error.

In my defense, I was very close to the solution.

I started with examining the mod_parse module, and there for the parse.login, body was used and the “content-type” in headers.

I searched the net and found that GET should not have a body, so I removed it, but the error was still there.

As mod_parse works on all other platforms I have tested, I assumed that the bug is on your side.

Seems that Windows is much more strict in HTTP calls.

Once again, thank you VERY MUCH for the help.

This will for sure help Windows Phone developers.

Happy to help!

Corona Engineers can’t track bugs in the forums. You will need to find a bug report using the “Report a bug” link at the top of the page. Your bug report requires a complete, buildable project; that is a main.lua, build.settings, config.lua and any resources needed to build. Please provide the minimal code that demonstrates the problem.

Thanks

Rob

I am sure your Engineers have some Windows Phone projects ready.

All they need to do is paste this code in the main.lua and call it.

I have lost a enough time on this.

Thank you.

I’m sorry you feel this way. I don’t know what other suggestions I can offer you at this point. If you refuse to submit the bug report, there isn’t much our engineers can do.

Rob

Hi Rob,

thank you very much for trying to help.

But this is not a super complicated case. 

Is is a very simple REST call.

I am sure the Engineers will take a look if you whisper to them:

“Hey guys, seems we have a bug in REST call with GET and custom headers for Windows Phone” :wink:

We have to have a bug report. It’s happened so many times where we take your forum code and simply pop it in an existing test app and we can’t find the problem because there is something else causing the problem. If this bug is important to you, please take the time and file a bug report. We can’t guess at what’s going on. We have been burned by this too many times and end up wasting too much time trying to guess at your setup.

In fact, if it’s as simple as you say, consider the time we’ve been going back and forth about this. You could have filed the bug already and I could have an engineer looking at it already. Now you’re looking at next week at the earliest.

Rob

I think it’s an issue with your “content-type” header.  It doesn’t make any sense to add that to your headers table since a “GET” request never pushes any content (ie: there’s no body; you’re not pushing any JSON data) to the server.  Comment it out.

Perhaps you meant to set the “accept” header to “application/json”?

Also note that Corona will just blindly push all of your header info (except for content-length) into the HTTP request on all platforms.  It’s up to you set up the headers correctly.  In this case, this error message is coming from the WP8 operating system.  It’s telling you that “GET” request are not allowed to have content, but you specify a content-type in the header.  This is just Microsoft validating your configuration.

Hi Joshua, thank you for your help.

That was it!

When I removed the “content-type”, no error.

In my defense, I was very close to the solution.

I started with examining the mod_parse module, and there for the parse.login, body was used and the “content-type” in headers.

I searched the net and found that GET should not have a body, so I removed it, but the error was still there.

As mod_parse works on all other platforms I have tested, I assumed that the bug is on your side.

Seems that Windows is much more strict in HTTP calls.

Once again, thank you VERY MUCH for the help.

This will for sure help Windows Phone developers.

Happy to help!