BUG - Network.request not accepting queries in the URL when running on Android.

Hello Scottrules44,

Can you possibly help me fix the issue I have?

How should the url be written? Like can you give me an example?

Thanks,

Estevan

function modParams(url, params)
local newURL = url … “?”
local first_arg = true
for i, v in pairs(params) do
if first_arg == false then
newURL = newURL … “&”
newURL = newURL … i … “=” … v
else
newURL = newURL … i … “=” … v
first_arg = false
end
end

local actualURL = nil
local url = "https://www.googleapis.com/drive/v3"
local requestParameters={}–enter params here
local myBody = {}–enter body here
local params = {}
local headers = {}
headers[“Content-Type”] = “application/json”
headers[“Authorization”] = "Bearer " … access_token
params.headers = headers
params.body = json.encode(myBody)
actualURL = modParams(url, requestParameters)
network.request(actualURL, method, function(event)
print(event.response)
end, params)

Hopefully my drive plugin get looked at soon. I have been waiting since July 6

Haha hopefully, I just watched the video that you were in. My question is with the plugin you demoed the application uploaded an arrow file when you pressed the request button. Were you able to do anything else with the plugin? I was able to upload and download files with my application. There will be a forum post here once I finish the update. The application has been released and available since August of last year. I got Google Drive integration to work, but I will look into this multiple query issue soon. If you want to check out my application check it out here: www.drivepad.weebly.com

Thanks,

Estevan

You should be able to do anything with the drive api. I have test uploading, deleting, downloading, and updating.

Edit: ^refering to files

What works fine?

If you use the params in the URL (as in GET) it will work for some servers, but query with GET is not supported on self hosted parse (dont know why but it doesn’t work, try it).

However, the method I showed (using the query arguments in the body) does work on the simulator but not on android. Problem is, I don’t really know what to show corona staff in the bug. I don’t have a test server for them to play with and I doubt they have one of their own.

Can you describe how you’re self-hosting Parse? Is it it’s own web server? Is it dependent on Apache or nginx? GET and POST are HTTP requests and have to be handled by a web server or something that responds as a web server.

Are you running this on your computer or you hosting it?

Rob

Also are you using the parse plugin on marketplace, mod_parse which is something Chris wrote long ago, another plugin or module I have not heard of ,or your own solution.

We use an ubunto cartridge on openshift. it has the basic express + nodejs implementation for parse. It works well except that one issue with queries. 

Do you have a different hosted parse version which works fine on such query?

We have the latest marketplace plug-in and mod_parse with latest fixes, switching between the two for each test hopefully to get something working.

have tried [==[I am a string &]==] instead of “I am a string &”
Basically use [==[]==] instead of quotes

Have you tried fully qualifying the URL:

https://mysite.com/wp-json/posts?filter[posts_per_page]=20&filter[category_name]=category

Yes, I’ve tried with the complete URL (including http://). I’m sure this is a bug, the same code works fine on iOS and is buggy on Android. 

I’m wondering if Android is sensitive to the []'s in your GET key-value pairs. Normally non-letter/numbers have to be URL encoded. You can use a function like:

local function urlencode(str) if (str) then str = string.gsub (str, "\n", "\r\n") str = string.gsub (str, "([^%w])", function (c) return string.format ("%%%02X", string.byte(c)) end) str = string.gsub (str, " ", "+") end return str end

and assemble your URL like:

local url = base\_url .. "/wp-json/posts?" .. urlencode("filter[posts\_per\_page]") .. "=20" .. "&  .. urlencode("filter[category\_name]") .. "=category"

If the values 20 and category can every contain non-letter/numbers you would need to encode them as well.

See if that helps.

Just tried the “urlencode” fix. Doesn’t work either.

Hey Rob, could you please check this our? I’m pretty sure I’m facing a Corona BUG. Please let me know how I can help you.

If you feel this is a bug, I encourage you to file a bug report. The bug report should contain a simple demonstration app that lets us build for device and run it and see the problem. Therefore it needs a main.lua, config.lua, build.settings, the actual URL’s you’re trying to access that causes the problem. Put the whole demo project in a .zip file and use the Report a Bug link at the top of the page.

You will get an email confirming the bug report. It will have a case ID number in the subject, please post that case ID number back here as a reference. I’ll grab the bug report and see if I can see the problem when I see your live production code. If it’s a bug, then it will be in the system. If not we will know the cause and you can proceed.

Rob

o

Has this issue been resolved? I’m facing probably a similar situation with our self hosted parse server. If there is a workaround would love to hear about it.

I can’t find a bug report for it.

Rob

Perhaps they worked around it somehow? Would love to know how…

Want params are you use in your parse request? Basically what your request look like. Are you use the parse plugin via corona marketplace, making your own, or using mod_parse