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 do you post Form data using your client in unity ? #15

Closed
arjuntilt opened this issue Mar 27, 2018 · 4 comments
Closed

How do you post Form data using your client in unity ? #15

arjuntilt opened this issue Mar 27, 2018 · 4 comments

Comments

@arjuntilt
Copy link

I have gone through your documentation and couldn't see any information regarding this. Could you please update some information or post an example of the same. I am trying to create a login page in unity using your plugin but I am not able to do it.

@jdnichollsc
Copy link
Member

Hi @arjuntilt, thanks for post this issue
Are you using a List<IMultipartFormSection> to create the formData? Can you share your code?
Best regards, Nicholls

@jdnichollsc
Copy link
Member

A moment ago, I reverted all the changes from the master branch to create a pull request to compare with the previous version of the plugin, I'm going to add a property BodyString from the RequestHelper class to send your JSON if you want to use other tool to serialize the code, so let me do that change and improve the code, any comments are really apreciated

Pull request => #18

Regards, Nicholls

@jdnichollsc
Copy link
Member

jdnichollsc commented May 20, 2018

@arjuntilt ok, with the last version of this plugin

  • Unity
List<IMultipartFormSection> form = new List<IMultipartFormSection>();

form.Add(new MultipartFormDataSection("firstName", "Juan"));
form.Add(new MultipartFormDataSection("lastName", "Nicholls"));

RestClient.Post(new RequestHelper {
    Uri = "http://localhost:8080",
    FormSections = form
})
.Then(res => EditorUtility.DisplayDialog ("Success", res.Text, "Ok"))
.Catch(err => EditorUtility.DisplayDialog ("Error", err.Message, "Ok"));
  • Backend (NodeJS, etc)
var express = require('express');
var router = express.Router();
var multipart = require('connect-multiparty');
var multipartMiddleware = multipart();

router.post('/', multipartMiddleware, function(req, res, next) {
  res.json({
    firstName: req.body.firstName,
    lastName: req.body.lastName
  })
});

captura de pantalla 2018-05-20 a la s 3 38 07 p m

@jdnichollsc
Copy link
Member

@arjuntilt any good comment from the Unity Asset Store would be really appreciated :)

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

No branches or pull requests

2 participants