Using Advanced REST Client to test REST Request - step by step
2017-08-31 09:48
806 查看
APP - 做auth2.0验证使用
Connected App设置后可以获得Consumer Key和Consumer Secret.
Consumer Key: 3MVG9ZL0ppGP5UrBPEyfde5VESRlM30EznnBnO3FlL49ozmrF97ee9NOgIUtbi5Nm8uPttY2Vsczpave8Jsxl
Consumer Secret: 4710087710557659561
How to connect Advanced REST Client?
Connected Link:
Do POST Request to get access_token and token_type:
1.使用GET方法查找数据:GET - R
https://componentstest-dev-ed.my.salesforce.com/services/data/v40.0/query?q=select
id, name from account
返回码:200,请求成功response the object’s information
注意:Headers form的Authorization的value格式:access_type+空格+access_token
2.使用POST方法创建记录:POST - C
https://componentstest-dev-ed.my.salesforce.com/services/data/v40.0/sobjects/account
返回码:201,创建成功response the record id
3.使用PATCH方法更新记录:PATCH - U https://componentstest-dev-ed.my.salesforce.com/services/data/v40.0/sobjects/account/0012800001VJIzuAAH 返回码:204,更新成功,无返回值no response
4.使用DELETE方法删除记录:DELETE - D「Content-Type is not required.」 https://componentstest-dev-ed.my.salesforce.com/services/data/v40.0/sobjects/account/0012800001VJIzuAAH 返回码:204,删除成功,无返回值no response
Q:: 为啥用同一个connect url post请求返回的
b144
access_token不一样?并且昨天使用的access_token今天使用会过期?
A:: access_token有有效时间的,外部系统对sf数据操作时,需要不定期获取access_token,当然sf可以设置过期时间如2h,12h等。
参考资料:https://www.slideshare.net/asagarwal/a-60-minutes-step-by-step-diy-guide-to-salesforce-rest-api-for-non-developers?qid=e6011c30-3581-4bcf-916f-30b7844c51da&v=&b=&from_search=1
如何获取consumer key和consumer secret链接:https://onlinehelp.coveo.com/en/ces/7.0/administrator/getting_salesforce_client_id_and_client_secret_values.htm
Connected App设置后可以获得Consumer Key和Consumer Secret.
Consumer Key: 3MVG9ZL0ppGP5UrBPEyfde5VESRlM30EznnBnO3FlL49ozmrF97ee9NOgIUtbi5Nm8uPttY2Vsczpave8Jsxl
Consumer Secret: 4710087710557659561
How to connect Advanced REST Client?
Connected Link:
https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id=3MVG9ZL0ppGP5UrBPEyfde5VESRlM30EznnBnO3FlL49ozmrF97ee9NOgIUtbi5Nm8uPttY2Vsczpave8Jsxl&client_secret=4710087710557659561&username=itsme@delloitte.com&password=admin123yF0cOjR6qMVFVN4IRJr4E6Hs
Do POST Request to get access_token and token_type:
{ "access_token": "00D28000000bNDI!AQMAQAziOABzixdUqHrVXsPt_SXeM455m4WsoqXbh4UaE1gU7yeZI8Cvui6Ycy1GRqE2nhXeDXC9vFUq.ipL2X3kDNXHu_tN1”, "instance_url": "https://componentstest-dev-ed.my.salesforce.com", "id": "https://login.salesforce.com/id/00D28000000bNDIEA2/00528000005ENAIAA4", "token_type": "Bearer", "issued_at": "1504051357502", "signature": "FdYNUzrkxeJApcivQAX0QIB5EmaNQjcKs7xIe5byYfk=" }
1.使用GET方法查找数据:GET - R
https://componentstest-dev-ed.my.salesforce.com/services/data/v40.0/query?q=select
id, name from account
返回码:200,请求成功response the object’s information
注意:Headers form的Authorization的value格式:access_type+空格+access_token
2.使用POST方法创建记录:POST - C
https://componentstest-dev-ed.my.salesforce.com/services/data/v40.0/sobjects/account
返回码:201,创建成功response the record id
3.使用PATCH方法更新记录:PATCH - U https://componentstest-dev-ed.my.salesforce.com/services/data/v40.0/sobjects/account/0012800001VJIzuAAH 返回码:204,更新成功,无返回值no response
4.使用DELETE方法删除记录:DELETE - D「Content-Type is not required.」 https://componentstest-dev-ed.my.salesforce.com/services/data/v40.0/sobjects/account/0012800001VJIzuAAH 返回码:204,删除成功,无返回值no response
Q:: 为啥用同一个connect url post请求返回的
b144
access_token不一样?并且昨天使用的access_token今天使用会过期?
A:: access_token有有效时间的,外部系统对sf数据操作时,需要不定期获取access_token,当然sf可以设置过期时间如2h,12h等。
参考资料:https://www.slideshare.net/asagarwal/a-60-minutes-step-by-step-diy-guide-to-salesforce-rest-api-for-non-developers?qid=e6011c30-3581-4bcf-916f-30b7844c51da&v=&b=&from_search=1
如何获取consumer key和consumer secret链接:https://onlinehelp.coveo.com/en/ces/7.0/administrator/getting_salesforce_client_id_and_client_secret_values.htm
相关文章推荐
- Step-By-Step Guide to Get Started with Salesforce REST API using Java
- [Project] Simulate HTTP Post Request to obtain data from Web Page by using Python Scrapy Framework
- Step By Step guide to Read XML file in Java Using SAX Parser Example
- [Project] Simulate HTTP Post Request to obtain data from Web Page by using Python Scrapy Framework
- Step By Step - Using Silverlight to Access a WCF Service Hosted In a Console Application
- How to simulate a Form POST request by using WinInet
- How to simulate a Form POST request by using WinInet
- Implementing Sugarcrm: A Step-by-step Guide to Using This Powerful Open Source Application in Your B
- How to simulate a Form POST request by using WinInet
- Step-by-Step Guide to XI Transports Using CMS
- A Step-by-Step Guide to Using iAd Workbench to Promote Your iOS Apps June 11, 2013, Raymond in Badmi
- kubernetes1.4 基础篇:Learn Kubernetes 1.4 by 6 steps(3):Step 2. Using kubectl to Create a Deployment
- Oracle 11g Active Data Guard step by step: How to create a Physical Standby Database using RMAN
- Step By Step Guide To Create Physical Standby Database Using RMAN Backup and Restore (Doc ID 469493.
- [Project] Simulate HTTP Post Request to obtain data from Web Page by using Python Scrapy Framework
- Using RestTemplate, how to send the request to a proxy first so I can use my junits with JMeter?
- 【ABAP】Creat a client-server demo to process a http request using SAP Web AS
- Step-By-Step Guide To Create Physical Standby On Normal File System For ASM Primary using RMAN (文档 I
- How to get blob data using javascript XmlHttpRequest by sync
- Step-By-Step Guide To Create Physical Standby On Normal File System For ASM Primary using RMAN