Collect submission to custom PHP script - "Invalid status code on Head request"

Hi,
my goal is to have PHP server for ODK. and I am using ken-muturi's PHP script, it's working all fine but in submission it's gives the
(formname - Error: Moved Permanently (301) at serverpath.

header('Server: Apache-Coyote/1.1');
header('Content-Type: application/xml;charset=UTF-8');
header( "Date: ".date('r'));
header('Content-Length: 1000000');
header('X-OpenRosa-Version: 1.0');
header('X-OpenRosa-Accept-Content-Length: 1048576000');

$filearray = array();
if( $_SERVER['REQUEST_METHOD'] === "HEAD" )
{
http_response_code(204);
}
elseif( $_SERVER['REQUEST_METHOD'] === "POST" )
{
http_response_code(201);
}

this is my code, but it's gives me me 301 error in ODK android app.

··· On Tuesday, April 18, 2017 at 2:45:02 AM UTC+4:30, Yaw Anokwa wrote: > Hi there, > > If you'd like help, you're going to have to provide a lot more context > about what your high-level goals are, what your implementation does, > what you've tried, etc. > > Yaw > > On Sat, Apr 15, 2017 at 4:17 AM, wrote: > > Hi, > > in my case, I am sending 204 for HEAD and 201 for POST but it replays with 301 > > > > (formname - Error: Moved Permanently (301) at serverpath. > > > > -- > > You received this message because you are subscribed to the Google Groups "ODK Developers" group. > > To unsubscribe from this group and stop receiving emails from it, send an email to opendatakit-developers+unsubscribe@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout.

Hi there,

Start directly from ken's script at
https://gist.github.com/ken-muturi/0f880e2cb1d19558e94ab05fc08797a6.
If that fails, then reach out to Ken directly for help. If that
works, then the problem is in your script and that goes beyond the
scope of the help that I can offer because it's been years since I touched PHP.

Thanks,

Yaw

··· On Tue, Apr 18, 2017 at 11:05 PM, wrote: > Hi, > my goal is to have PHP server for ODK. and I am using ken-muturi's PHP script, it's working all fine but in submission it's gives the > (formname - Error: Moved Permanently (301) at serverpath. > > header('Server: Apache-Coyote/1.1'); > header('Content-Type: application/xml;charset=UTF-8'); > header( "Date: ".date('r')); > header('Content-Length: 1000000'); > header('X-OpenRosa-Version: 1.0'); > header('X-OpenRosa-Accept-Content-Length: 1048576000'); > > $filearray = array(); > if( $_SERVER['REQUEST_METHOD'] === "HEAD" ) > { > http_response_code(204); > } > elseif( $_SERVER['REQUEST_METHOD'] === "POST" ) > { > http_response_code(201); > } > > this is my code, but it's gives me me 301 error in ODK android app. > > > On Tuesday, April 18, 2017 at 2:45:02 AM UTC+4:30, Yaw Anokwa wrote: >> Hi there, >> >> If you'd like help, you're going to have to provide a lot more context >> about what your high-level goals are, what your implementation does, >> what you've tried, etc. >> >> Yaw >> >> On Sat, Apr 15, 2017 at 4:17 AM, wrote: >> > Hi, >> > in my case, I am sending 204 for HEAD and 201 for POST but it replays with 301 >> > >> > (formname - Error: Moved Permanently (301) at serverpath. >> > >> > -- >> > You received this message because you are subscribed to the Google Groups "ODK Developers" group. >> > To unsubscribe from this group and stop receiving emails from it, send an email to opendatakit-developers+unsubscribe@googlegroups.com. >> > For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups "ODK Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an email to opendatakit-developers+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/d/optout.

Hi,
With this code, it gives me the invalid header error which Ken receives

··· -----Original Message----- From: opendatakit-developers@googlegroups.com [mailto:opendatakit-developers@googlegroups.com] On Behalf Of Yaw Anokwa Sent: Thursday, April 20, 2017 5:34 AM To: ODK Developers Subject: Re: [ODK Developers] Re: Collect submission to custom PHP script - "Invalid status code on Head request"

Hi there,

Start directly from ken's script at
https://gist.github.com/ken-muturi/0f880e2cb1d19558e94ab05fc08797a6.
If that fails, then reach out to Ken directly for help. If that works, then the problem is in your script and that goes beyond the scope of the help that I can offer because it's been years since I touched PHP.

Thanks,

Yaw

On Tue, Apr 18, 2017 at 11:05 PM, m.naser.sobhan@gmail.com wrote:

Hi,
my goal is to have PHP server for ODK. and I am using ken-muturi's PHP
script, it's working all fine but in submission it's gives the (formname - Error: Moved Permanently (301) at serverpath.

header('Server: Apache-Coyote/1.1');
header('Content-Type: application/xml;charset=UTF-8'); header( "Date:
".date('r'));
header('Content-Length: 1000000');
header('X-OpenRosa-Version: 1.0');
header('X-OpenRosa-Accept-Content-Length: 1048576000');

$filearray = array();
if( $_SERVER['REQUEST_METHOD'] === "HEAD" ) {
http_response_code(204);
}
elseif( $_SERVER['REQUEST_METHOD'] === "POST" ) {
http_response_code(201);
}

this is my code, but it's gives me me 301 error in ODK android app.

On Tuesday, April 18, 2017 at 2:45:02 AM UTC+4:30, Yaw Anokwa wrote:

Hi there,

If you'd like help, you're going to have to provide a lot more
context about what your high-level goals are, what your
implementation does, what you've tried, etc.

Yaw

On Sat, Apr 15, 2017 at 4:17 AM, m.naser.sobhan@gmail.com wrote:

Hi,
in my case, I am sending 204 for HEAD and 201 for POST but it
replays with 301

(formname - Error: Moved Permanently (301) at serverpath.

--
You received this message because you are subscribed to the Google Groups "ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "ODK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/opendatakit-developers/PFWsIb3nnTk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mohammad,

I couldnt get to work with PHP.

So i just went ahead and wrote a small Python-flask app.
https://github.com/ken-muturi/odk-flask.

Thanks

··· On Thu, Apr 20, 2017 at 6:48 AM, Mohammad Naser < outlook_DC88CFD2DBAC477D@outlook.com> wrote:

Hi,
With this code, it gives me the invalid header error which Ken receives

-----Original Message-----
From: opendatakit-developers@googlegroups.com [mailto:opendatakit-
developers@googlegroups.com] On Behalf Of Yaw Anokwa
Sent: Thursday, April 20, 2017 5:34 AM
To: ODK Developers
Subject: Re: [ODK Developers] Re: Collect submission to custom PHP script

  • "Invalid status code on Head request"

Hi there,

Start directly from ken's script at
https://gist.github.com/ken-muturi/0f880e2cb1d19558e94ab05fc08797a6.
If that fails, then reach out to Ken directly for help. If that works,
then the problem is in your script and that goes beyond the scope of the
help that I can offer because it's been years since I touched PHP.

Thanks,

Yaw

On Tue, Apr 18, 2017 at 11:05 PM, m.naser.sobhan@gmail.com wrote:

Hi,
my goal is to have PHP server for ODK. and I am using ken-muturi's PHP
script, it's working all fine but in submission it's gives the (formname

  • Error: Moved Permanently (301) at serverpath.

header('Server: Apache-Coyote/1.1');
header('Content-Type: application/xml;charset=UTF-8'); header( "Date:
".date('r'));
header('Content-Length: 1000000');
header('X-OpenRosa-Version: 1.0');
header('X-OpenRosa-Accept-Content-Length: 1048576000');

$filearray = array();
if( $_SERVER['REQUEST_METHOD'] === "HEAD" ) {
http_response_code(204);
}
elseif( $_SERVER['REQUEST_METHOD'] === "POST" ) {
http_response_code(201);
}

this is my code, but it's gives me me 301 error in ODK android app.

On Tuesday, April 18, 2017 at 2:45:02 AM UTC+4:30, Yaw Anokwa wrote:

Hi there,

If you'd like help, you're going to have to provide a lot more
context about what your high-level goals are, what your
implementation does, what you've tried, etc.

Yaw

On Sat, Apr 15, 2017 at 4:17 AM, m.naser.sobhan@gmail.com wrote:

Hi,
in my case, I am sending 204 for HEAD and 201 for POST but it
replays with 301

(formname - Error: Moved Permanently (301) at serverpath.

--
You received this message because you are subscribed to the Google
Groups "ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google
Groups "ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the
Google Groups "ODK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/
topic/opendatakit-developers/PFWsIb3nnTk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the
Google Groups "ODK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/
topic/opendatakit-developers/PFWsIb3nnTk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mohammad,

I couldnt get to work with PHP.

I can sympathize - I had a LOT of problems getting submission to ODK
Aggregate to work in my (non-ODK) XForms client. In the end I resorted to
first getting it working at the very basic end of the spectrum, using curl.
Then when that was working, I could tweak my client to ensure it spit out
the exact same HTTP blob. I might suggest you try something similar

This worked for me (adapt to your own simple hello world form):

Gareths-MacBook-Pro:XForms bestor$ cat instance.xml

<?xml version="1.0" encoding="UTF-8"?>

Gareth
Bestorna

Gareths-MacBook-Pro:XForms bestor$ curl -v -k -X POST -d @instance.xml -H
"X-OpenRosa-Version:1.0" -H "Date:Thu, 09 Mar 2017 14:03:47 NZDT" -H
"Content-Type:text/xml" https://ODKAggregate:8443/ODKAggregate/submission

  • Trying 192.168.178.43...
  • Connected to ODKAggregate (192.168.178.43) port 8443 (#0)
  • TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
  • Server certificate: ODKAggregate

POST /ODKAggregate/submission HTTP/1.1
Host: ODKAggregate:8443
User-Agent: curl/7.43.0
Accept: /
X-OpenRosa-Version:1.0
Content-Type:text/xml
Content-Length: 238

  • upload completely sent off: 238 out of 238 bytes
    < HTTP/1.1 201 Created
    < Server: Apache-Coyote/1.1
    < Location: https://ODKAggregate:8443/ODKAggregate/submission
    < X-OpenRosa-Version: 1.0
    < Date: Thu, 27 Apr 2017 21:32:48 GMT
    < X-OpenRosa-Accept-Content-Length: 10485760
    < Content-Type: text/xml;charset=UTF-8
    < Content-Length: 382
    <
  • Connection #0 to host ODKAggregate left intact
    full
    submission upload was successful!

curl -v is great because it shows you everything in the HTTP request that
is actually sent up (and if any of this is missing ODK Aggregate will
likely barf), and everything that ODK responds with. Make sure your PHP
client spits out the same, and you should be good.

Note, I dont include any attachments above, so I'm just sending the XML
instance. There's more that needs to be done - and you have to get right -
to upload, say, images in your submission. But first just get the simple
case working. Then if you have problems uploading images just ask.

  • Gareth
··· On Friday, April 21, 2017 at 6:47:54 PM UTC+12, Ken Muturi wrote: > Date:Thu, 09 Mar 2017 14:03:47 NZDT

Opps, sorry, I just realized yer trying to do this at the server end
(doh!). Oh well, perhaps there is still something in the headers here that
will help...