Web services 尝试将JSON发布到URL上

Web services 尝试将JSON发布到URL上,web-services,Web Services,我正在进行申请流程的第二步。第一步是对URL使用GET方法并检索名称和电子邮件地址 以下是网址: 现在我被要求发布一个JSON对象。问题是: Congratulations John Quach, you completed Step 1! Step 2 is as follows: Perform a POST to the URL you constructed in Step 1. You will need to post an instance of the application

我正在进行申请流程的第二步。第一步是对URL使用GET方法并检索名称和电子邮件地址

以下是网址:

现在我被要求发布一个JSON对象。问题是:

Congratulations John Quach, you completed Step 1!

Step 2 is as follows:
Perform a POST to the URL you constructed in Step 1.
You will need to post an instance of the application object described below.
You will need to post the body in properly formatted JSON.
You will need to pass in all required headers.
Please set the isTest boolean to TRUE while testing, and FALSE when you are ready for your final submission.
application {
Boolean isTest (required)
String firstName (required)
String lastName (required)
String email (required)
String phone (required)
String zipcode (required)
String describeYourself (required)
ool[] objectLanguages (required)
education[] education (required)
experience[] experience (required)
certification[] certs
}

education {
String school (required)
Integer graduationYear (required)
String degree (required)
String major (required)
}

experience {
String company (required)
Date fromDate [yyyy-MM-dd] (required)
Date toDate [yyyy-MM-dd] (required)
String title (required)
String workDone (required)
}

certification {
String certification (required)
Date dateCertified [yyyy-MM-dd] (required)
}

ool {
String language (required) [must include at least 'javascript'; include any other OOP languages you know]
Integer proficiency (required) [scale of 0-10, 0 being none, 10 being proficient]
}

A successful post will result in a code 202 and you will receive an automated email confirmation. Good Luck!
我试过很多密码。我遵循了你的建议,并根据你给出的代码使用了它。我正在通过HTML页面使用javascript

 <script> 
var webLink = "https://mkpartners.secure.force.com/services/apexrest/careers?firstName=John&lastName=Quach&email=johnq1216@gmail.com"; 


var apply = {
         isTest : false,
         firstName : "John",
         lastName : "Quach",
         email : "johnq1216@gmail.com",
         phone : 6269355016,
         zipcode : 91207,
         describeYourself : "Self Taught Programmer and Developer"
    }


function httpPost(theUrl) {
    var xmlHttp = null;
    xmlHttp = new XMLHttpRequest();         
    xmlHttp.open( "POST", theUrl, false);    
    xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); 
    xmlHttp.send(JSON.stringify(apply)); 
}  


httpPost(webLink); 
</script>
//This script will make a POST request. Read above comments.

var webLink=”https://mkpartners.secure.force.com/services/apexrest/careers?firstName=John&lastName=Quach&email=johnq1216@gmail.com“;
变量应用={
伊斯特:错,
名字:“约翰”,
姓:“鹌鹑”,
电子邮件:“johnq1216@gmail.com",
电话:6269355016,
邮编:91207,
自我描述:“自学成才的程序员和开发人员”
}
函数httpPost(theUrl){
var xmlHttp=null;
xmlHttp=新的XMLHttpRequest();
open(“POST”,theUrl,false);
setRequestHeader(“内容类型”,“应用程序/json;字符集=UTF-8”);
send(JSON.stringify(apply));
}  
httpPost(webLink);
//此脚本将发出POST请求。阅读以上评论。
当然,这些都不管用。我做错了什么?我是否需要包含语言、教育和认证对象的完整JSON对象?我之所以把它们漏掉,是因为我想从网站上得到一些回应,我想把答案保持在小范围内

要将这个JSON对象发布到URL,我需要的不仅仅是计算机上的记事本吗

您的json无效

var json =   {
    firstName : "John",
    lastName : "Quach",
    email : "johnq1216@gmail.com"
};
send(字符串)仅适用于POST动词

xmlhttp.open("POST", ,"demo_post.asp",true);
xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xmlhttp.send(JSON.stringify(json);
//您仍然需要进行JSON编码。为此使用JSON编码器,然后发出请求。将处理后得到的JSON对象作为参数传递到HTTPPOST中。
var webLink=”https://mkpartners.secure.force.com/services/apexrest/careers"; 
var MoreComplified={firstName:“John”,lastName:“Quach”,电子邮件:johnq1216@gmail.com" } 
函数httpPost(theUrl){
var xmlHttp=null;
xmlHttp=新的XMLHttpRequest();
open(“POST”,theUrl,false);
setRequestHeader(“内容类型”,“应用程序/json;字符集=UTF-8”);
send(JSON.stringify(moreSimplified));
}  
httpPost(webLink);
//此脚本将发出POST请求。阅读以上评论。

1。这不是JSON;2.如果你需要“发布”,为什么要使用“获取”?你能检查一下我的答案吗?其实很好。只是我没有为JSON编码添加代码。谢谢,但我没有得到任何东西。我重新编辑了我的原始帖子,以反映您的更改,并对我自己的帖子进行了一些小调整。我需要做什么才能从该URL的链接获得特定响应?我的windows电脑需要更多的记事本吗?好的,我想我找到了问题所在的区域。我注意到,一旦Javascript无法运行语句,它将忽略此后的任何语句。我已经删除了语句“setRequestHeader”,我注意到chrome左下角的文本显示它试图建立到URL的连接。@user1623873您没有得到任何东西,因为如果您不编码JSON,您不应该得到任何东西。首先对JSON进行编码,然后发布。
//You will still have to do the JSON encoding. Use the JSON encoder for this and then make the request. Pass the JSON object you get after processing into http post as a parameter.
<script> 
var webLink = "https://mkpartners.secure.force.com/services/apexrest/careers"; 
var moreSimplified = { firstName : "John", lastName : "Quach", email : "johnq1216@gmail.com" } 
function httpPost(theUrl) {
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();         
xmlHttp.open( "POST", theUrl, false);    
xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); 
xmlHttp.send(JSON.stringify(moreSimplified)); 
}  
httpPost(webLink); 
</script>
//This script will make a POST request. Read above comments.