Skip to content
This repository has been archived by the owner on May 28, 2020. It is now read-only.

Calls to the non-customised Kobo API giving 400 error #21

Open
dave-mills opened this issue May 31, 2018 · 5 comments
Open

Calls to the non-customised Kobo API giving 400 error #21

dave-mills opened this issue May 31, 2018 · 5 comments

Comments

@dave-mills
Copy link
Member

You wanted another bug tag...

I suspect it's something tiny about how the default pipeRequest is setting options / headers.

I'm getting the error below while trying to add a form to a project. Had the same issue last night when sharing forms with users. Wrote a shareFormWithUser function (see 'late-night-hacks' branch), that is a clone of other share functions and works fine.

Could also be because the pipeRequest isn't updated to async like the others?


Example:

Trying to send to ${api-url}/projects/1/forms to add new form, and getting:

{"error":"unsuccessful request","options":{"method":"POST","url":"https://nrc-kobocat.stats4sdtest.online/api/v1/projects/1/forms","headers":{"authorization":"Token 439529b2f08052c6519d690afc76476c0a96a882"}},"response":{"statusCode":400,"body":"{\"text\":\"Invalid URL format.\",\"type\":\"alert-error\"}","headers":{"server":"nginx/1.10.3 (Ubuntu)","date":"Thu, 31 May 2018 10:46:12 GMT","content-type":"application/json","transfer-encoding":"chunked","connection":"close","vary":"Accept, Accept-Language, Cookie","content-language":"en","allow":"GET, POST, HEAD, OPTIONS"},"request":{"uri":{"protocol":"https:","slashes":true,"auth":null,"host":"nrc-kobocat.stats4sdtest.online","port":443,"hostname":"nrc-kobocat.stats4sdtest.online","hash":null,"search":null,"query":null,"pathname":"/api/v1/projects/1/forms","path":"/api/v1/projects/1/forms","href":"https://nrc-kobocat.stats4sdtest.online/api/v1/projects/1/forms"},"method":"POST","headers":{"authorization":"Token 439529b2f08052c6519d690afc76476c0a96a882","content-length":0}}},"body":"{\"text\":\"Invalid URL format.\",\"type\":\"alert-error\"}"}
@dave-mills
Copy link
Member Author

(Not marked as urgent, as it's working, stable and fast for me to add a couple of (technically un-needed) endpoints for the things that should be vanilla API calls. )

I'm going to keep these extra ones on the hacking branch to make it easier to kill them later :-)

@chrismclarke
Copy link
Contributor

I have a feeling it might be to do with my 'oh wait, we don't even use the request for anything anyway' comment yesterday before gutting the proxied request away. I assume things like referrer are passed in the request headers and need to be included. Will investigate

@chrismclarke chrismclarke self-assigned this May 31, 2018
@chrismclarke
Copy link
Contributor

actually I'm not sure what the error is there, it has sent the post request however it appears to be the post body that doesn't seem to be formatted correctly. Can you confirm what was sent was of the format {formid:123}? For me the attached query works (have you also tried GET request?).

@chrismclarke
Copy link
Contributor

I'll add that everything works fine for me, proxying through to the standard kobo server. I wonder if it might be to do with nginx server headers/cors on the custom kobo server... would be good to know, but yes no harm just adding on a custom referrer for now

@chrismclarke
Copy link
Contributor

I meant to write something to help clarify this but changes didn't save. From what I can remember this linked to:

  1. The /form{pk}/share native endpoint wasn't behaving correctly. From postman it works as intended and possibly even node so need to investigate why it's not working correctly on app.

2.Unrelated but need to find a way to also unshare, have attempted various possible post/delete/put requests and none seem to work.

  1. Then need to test from proxy requests.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants