我有一组数据:
var myArray = [{"id": 1, "name", "John"},{"id": 2, "name", "Joe"},{"id": 3, "name", "Bill"}]
$.post("/MyController/Update", myArray, function (data) {
alert("Complete");
});
Run Code Online (Sandbox Code Playgroud)
这是我的 asp.net-mvc 控制器操作
public ActionResult Update(List<Person> people)
{
return Json(new {Success = true});
}
public class Person
{
public int id {get;set;}
public string name {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
var paramString = JSON.stringify({ people: myArray});
$.post("/MyController/Update", paramString , function (data) {
alert("Complete");
});
Run Code Online (Sandbox Code Playgroud)
但是当我查看服务器上的 people 参数时,我要么看到:
关于我在这里做错了什么有什么建议吗?
问题:尝试将讲师的python 2代码翻译为python 3
具体问题:无法从 python 3 中的表单访问消息字段
def do_POST(self):
try:
self.send_response(301)
self.send_header('Content-type', 'text/html')
self.end_headers()
ctype, pdict = cgi.parse_header(
self.headers.getheader('content-type'))
if ctype == 'multipart/form-data':
fields = cgi.parse_multipart(self.rfile, pdict)
messagecontent = fields.get('message')
output = ""
output += "<html><body>"
output += " <h2> Okay, how about this: </h2>"
output += "<h1> %s </h1>" % messagecontent[0]
output += '''<form method='POST' enctype='multipart/form-data' action='/hello'><h2>What would you like me to say?</h2><input name="message" type="text" ><input type="submit" value="Submit"> </form>'''
output += …Run Code Online (Sandbox Code Playgroud) 我正在使用 Postman v4.9.3,我正在尝试使用 POST 请求查看页面响应。问题是,当单击“预览”按钮时,未加载外部 CSS。有人可以帮我解决吗?或者是否有其他方法使用 POST 请求页面并设置一些标头,然后渲染返回的页面?
我知道 php.ini 的值max_input_vars默认为 1000(我使用的是 5.6 版)。我的 POST 数据被截断了,所以我需要增加这个值。这确实解决了我的问题。在更改这些值时,我只是想了解它实际上具体影响了什么。
如果我向后端发送一组数据,这是否意味着它只能包含大约 1000 个元素?看起来我的表单总和没有达到 1000 个输入字段,所以我试图弄清楚这个数字是做什么用的。
我可以达到的安全高数是多少?10000会不会太高了?
我是keycloak 的新手,任何帮助都是可观的。我可以使用 keycloak api 获取用户详细信息列表,我想知道如何使用 http-post 获取它。
Keycloak kc = Keycloak.getInstance("url-path", "realm", "username", "password", "admin-cli");
Run Code Online (Sandbox Code Playgroud)
通过使用这个 keycloak 对象,我可以获得用户列表。但是,当我想通过使用 keycloak 提供的端点 url 使用 http-post 或 rest api 调用获取用户列表时,我无法根据令牌获取访问令牌,我只获取特定用户,我想要使用rest api的用户列表。
我想通过自定义控制器和登录页面更好地控制登录和注销。
我的 SecurityConfiguration 代码目前如下所示:
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private SpringDataJpaUserDetailsService userDetailsService;
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.userDetailsService(this.userDetailsService)
.passwordEncoder(Manager.PASSWORD_ENCODER);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/resources/**", "/built/**", "/main.css", "/login.css").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.loginProcessingUrl("/loginSecure")
.defaultSuccessUrl("/index", true)
.permitAll()
.usernameParameter("username").passwordParameter("password")
.and()
.csrf().disable()
.logout()
.permitAll();
}
}
Run Code Online (Sandbox Code Playgroud)
我的控制器中的登录配置:
@RequestMapping(value = "/login")
public String login() {
return "login";
}
Run Code Online (Sandbox Code Playgroud)
我的控制器中的 loginSecure 映射:
@RequestMapping(value="/loginSecure", method = RequestMethod.POST)
public String …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用他们的 Api(https://www.file.io/#one,见下文)在 Excel 中使用 VBA上传https://file.io文件。
我发现这个线程如何将文件上传到 file.io 并获取链接,但是,我不知道如何准确地将它从 C# 传输到 VBA。
File.io 上的语法是:
$ curl -F "file=@test.txt" https://file.io
{"success":true,"key":"2ojE41","link":"https://file.io/2ojE41","expiry":"14 days"}
$ curl https://file.io/2ojE41
This is a test
$ curl https://file.io/2ojE41
{"success":false,"error":404,"message":"Not Found"}
Run Code Online (Sandbox Code Playgroud)
我当前的代码如下所示:
Set objhttp = CreateObject("MSXML2.ServerXMLHTTP")
URL = "https://file.io"
objhttp.Open "post", URL, False
objhttp.setRequestHeader "Content-type", "application/json"
objhttp.Send ("file=@C:/Users/me/Downloads/image.jpg")
Debug.Print objhttp.responsetext
Run Code Online (Sandbox Code Playgroud)
我的响应文本说:
{"success":false,"error":400,"message":"Trouble uploading file"}
Run Code Online (Sandbox Code Playgroud)
我什至不确定路径中的“@”或者是否通常使用标准文件夹等。提前非常感谢!感谢所有帮助。
我知道有很多关于同样问题的问题,但没有一个解决方案对我有用。
我有一个使用 Lumen 内置 API 的 ReactJS 应用程序。该 API 也被React Native和JQuery AJAX 使用,并且在两者上都可以正常工作。
当我尝试从 ReactJS 发送带有 axios的POST请求时,我在OPTIONS请求中收到 405 Method Not Allowed 错误。
axios 请求是:
const body = { username, password };
axios.post(`{$uri}/payment/api/login`, {body})
.then(res => console.log(res))
.catch(err => console.log('Login: ', err));
Run Code Online (Sandbox Code Playgroud)
起初我认为这是一个 CORS 问题,这会很奇怪,因为我的 API 被托管在 AWS S3 上的静态站点使用,没有任何问题。所以我的 CORS 中间件工作正常。
比我尝试使用 fetchAPI 来调用 API 并且工作正常。我尝试从 axios向虚拟 API https://jsonplaceholder.typicode.com/users发送POST请求,并且工作正常。
编辑
好的,所以我刚刚发现 fetchAPI 以application/x-www-form-urlencoded格式发送数据,该格式不受飞行前请求的影响。这应该意味着 CORS 中间件存在问题。
CORSM中间件
<?php …Run Code Online (Sandbox Code Playgroud) 有没有办法指定 swagger 的示例请求?甚至可能是多个?
该Try it out按钮仅显示通用值,例如:
{
"firstName": "string",
"lastName": "string"
}
Run Code Online (Sandbox Code Playgroud)
为了
public class User
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
当您必须首先编辑所有值时,使用大型对象变得非常困难。我知道我可以使用 Postman,我也可以使用,但是能够使用 swagger创建多个美观且有用的示例会非常好。
我试图了解如何使用 Boost Beast 库处理 HTTP POST 请求的内容。我稍微修改了Boost Beast 高级服务器示例来掌握一些事情。
我已将以下几行添加到示例中的 handle_request() 方法中(就在第 155 行之前):
if ( req.method() == http::verb::post)
{
std::cout << req << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个名为 foobar.dat 的简单测试文件,其中包含以下内容:
This is a test!
Run Code Online (Sandbox Code Playgroud)
我使用以下curl命令将其发送到服务器:
curl -F 'test=@foobar.dat' http://localhost:8080
Run Code Online (Sandbox Code Playgroud)
这会导致服务器输出以下内容:
POST / HTTP/1.1Host: localhost:8080
User-Agent: curl/7.58.0
Accept: */*
Content-Length: 218
Content-Type: multipart/form-data; boundary=------------------------9c747f078ebbe880
--------------------------9c747f078ebbe880
Content-Disposition: form-data; name="test"; filename="foobar.dat"
Content-Type: application/octet-stream
This is a test!
--------------------------9c747f078ebbe880--
Run Code Online (Sandbox Code Playgroud)
所以,我让服务器接收预期的消息。
如果我将测试稍微修改为以下内容,我可以单独提取标头字段以及一个大缓冲区中的正文。
if ( req.method() == http::verb::post)
{
std::cout << "Fields:" << std::endl;
int …Run Code Online (Sandbox Code Playgroud) http-post ×10
forms ×2
ajax ×1
apache ×1
api ×1
asp.net-mvc ×1
axios ×1
boost ×1
boost-beast ×1
c# ×1
c++ ×1
html ×1
java ×1
javascript ×1
jquery ×1
json ×1
lumen ×1
php ×1
post ×1
postman ×1
python ×1
python-2.7 ×1
python-3.x ×1
reactjs ×1
spring-boot ×1
swagger ×1
vba ×1