Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make multi-part/form-data request in edge_http_client package? #22

Open
Ansh-Rathod opened this issue Apr 16, 2023 · 6 comments
Open

Comments

@Ansh-Rathod
Copy link

Hey guys, loving this package in the edge function. but any plans to add muliPartRequest to the package?

@Ansh-Rathod Ansh-Rathod changed the title How to make multi-part/form-data request in runtime? How to make multi-part/form-data request in edge_http_client pacakge? Apr 16, 2023
@Ansh-Rathod Ansh-Rathod changed the title How to make multi-part/form-data request in edge_http_client pacakge? How to make multi-part/form-data request in edge_http_client package? Apr 16, 2023
@Ehesp
Copy link
Member

Ehesp commented Apr 16, 2023

@Ansh-Rathod ill have to investigate, however it should theoretically work, have you tried?

Cc @lesnitsky

@Ansh-Rathod
Copy link
Author

@Ansh-Rathod ill have to investigate, however it should theoretically work, have you tried?

Cc @lesnitsky

yeah, i tried this, the major issue i think is it didn't added proper headers to request. every time headers was empty and response became 400 bad request.

@Ehesp
Copy link
Member

Ehesp commented Apr 17, 2023

Could you share the code? Will add a test case

@MichealReed
Copy link

MichealReed commented Jun 19, 2023

@Ansh-Rathod how did you get this working? I can't find MultipartRequest anywhere in the edge library, and using the traditional http lib triggers

<ref *1> UnsupportedError {
  message: "Cannot create a client without dart:html or dart:io.",
  "$thrownJsError": <ref *2> Unsupported operation: Cannot create a client without dart:html or dart:io.
    at Object.wrapException (file:///src/main.dart.js:698:17)
    at Object.throwExpression (file:///src/main.dart.js:712:15)
    at Object.createClient (file:///src/main.dart.js:6951:16)
    at Object.Client_Client (file:///src/main.dart.js:6947:18)
    at file:///src/main.dart.js:13071:26
    at _wrapJsFunctionForAsync_closure.$protected (file:///src/main.dart.js:3324:15)
    at _wrapJsFunctionForAsync_closure.call$2 (file:///src/main.dart.js:8780:12)
    at Object._asyncStartSync (file:///src/main.dart.js:3288:20)
    at MultipartRequest.send$0 (file:///src/main.dart.js:13076:16)
    at file:///src/main.dart.js:14098:48 {
    dartException: [Circular *1],
    name: "",
    "$cachedTrace": _StackTrace { _exception: [Circular *2], _trace: null }
  }
}

and when trying with the provided fetch --

final mulitResponse = await edge.fetch(edge.Resource.request(httpRequest));

I see

The argument type 'MultipartRequest' can't be assigned to the parameter type 'Request'.dart[argument_type_not_assignable](https://dart.dev/diagnostics/argument_type_not_assignable)

nor does edge.fetch appear to support a StreamedResponse, which is what should be used in conjunction with MultipartRequest.

@Ansh-Rathod
Copy link
Author

well, if you use runtimeclient with HTTP library.

@MichealReed
Copy link

MichealReed commented Jun 20, 2023

well, if you use runtimeclient with HTTP library.

The problem is not with http, but the missing html/io libraries. Are you sure you got this working? Could you please share code? If it was not working for you please say so Invertase can prioritize this to be fixed.

I tried with

http.runWithClient(() => getResponse, () => EdgeHttpClient());

as well.

Any thoughts @Ehesp?

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

No branches or pull requests

3 participants