guides:ws_payloads_send_payload
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| guides:ws_payloads_send_payload [2020/08/23 18:28] – brett.zamora | guides:ws_payloads_send_payload [2024/03/18 17:51] (current) – greg.dapkus | ||
|---|---|---|---|
| Line 16: | Line 16: | ||
| {{tablelayout? | {{tablelayout? | ||
| ^ Method ^ URL ^ | ^ Method ^ URL ^ | ||
| - | | GET | < | + | | POST | < |
| Line 83: | Line 83: | ||
| ---- | ---- | ||
| + | |||
| + | |||
| + | **Comment 1:** | ||
| + | |||
| + | Following is a C# / .NET sample code snippet that shows how to call the web services associated with sending a local payload to a remote folder. | ||
| + | |||
| + | This snippet was derived from the [[guides: | ||
| + | |||
| + | |||
| + | <code C#> | ||
| + | private bool SendFile(string strRepositoryType, | ||
| + | { | ||
| + | tbMessageLine.Text = ""; | ||
| + | |||
| + | bool rc = false; | ||
| + | |||
| + | RestClient client = null; | ||
| + | RestRequest request = null; | ||
| + | IRestResponse response = null; | ||
| + | |||
| + | string strURL = " | ||
| + | |||
| + | // Password has to be hashed. | ||
| + | // New convention uses a Salt value from the user record | ||
| + | // See the Login documentation for more detail | ||
| + | |||
| + | string strSalt = GetSalt(tbUserName.Text); | ||
| + | string strPassword = tbPassword.Password.ToString(); | ||
| + | |||
| + | string strHashedPassword = HashPassword(strPassword, | ||
| + | |||
| + | string strParms = " | ||
| + | strParms += tbUserName.Text; | ||
| + | strParms += " | ||
| + | strParms += strHashedPassword; | ||
| + | strParms += " | ||
| + | |||
| + | client = new RestClient(strURL); | ||
| + | request = new RestRequest(Method.POST); | ||
| + | |||
| + | request.AddHeader(" | ||
| + | request.AddHeader(" | ||
| + | |||
| + | request.AddParameter(" | ||
| + | response = client.Execute(request); | ||
| + | |||
| + | if (response.IsSuccessful) | ||
| + | { | ||
| + | tbMessageLine.Text = " | ||
| + | | ||
| + | var jsonResult1 = JsonConvert.DeserializeObject< | ||
| + | string token = jsonResult1.access_token; | ||
| + | |||
| + | FileStream fs = new FileStream(strFileName, | ||
| + | |||
| + | XmlDocument xmlDoc = new XmlDocument(); | ||
| + | |||
| + | xmlDoc.Load(fs); | ||
| + | |||
| + | strURL = null; | ||
| + | client = null; | ||
| + | request = null; | ||
| + | response = null; | ||
| + | |||
| + | strURL = " | ||
| + | |||
| + | client = new RestClient(strURL); | ||
| + | request = new RestRequest(Method.POST); | ||
| + | |||
| + | request.AddHeader(" | ||
| + | request.AddHeader(" | ||
| + | request.AddHeader(" | ||
| + | request.AddParameter(" | ||
| + | response = client.Execute(request); | ||
| + | |||
| + | if (response.IsSuccessful) | ||
| + | { | ||
| + | var jsonResult2 = JsonConvert.DeserializeObject< | ||
| + | string strRemoteFileName = jsonResult2.result; | ||
| + | |||
| + | // You must finalize the remote file to change the extension from .tmp to .xml | ||
| + | | ||
| + | string strAction = " | ||
| + | |||
| + | strURL = null; | ||
| + | client = null; | ||
| + | request = null; | ||
| + | response = null; | ||
| + | |||
| + | strURL = " | ||
| + | |||
| + | client = new RestClient(strURL); | ||
| + | request = new RestRequest(Method.PATCH); | ||
| + | |||
| + | request.AddHeader(" | ||
| + | request.AddHeader(" | ||
| + | response = client.Execute(request); | ||
| + | |||
| + | if (response.IsSuccessful) | ||
| + | { | ||
| + | tbMessageLine.Text = "XML file " + strFileName+" | ||
| + | rc = true; | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | var jsonResult3 = JsonConvert.DeserializeObject< | ||
| + | string strMessage = jsonResult3.Exception.Message; | ||
| + | tbMessageLine.Text = strMessage; | ||
| + | } | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | var jsonResult2 = JsonConvert.DeserializeObject< | ||
| + | string strMessage = jsonResult2.Exception.Message; | ||
| + | tbMessageLine.Text = strMessage; | ||
| + | } | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | var jsonResult2 = JsonConvert.DeserializeObject< | ||
| + | tbMessageLine.Text = jsonResult2.ToString(); | ||
| + | } | ||
| + | |||
| + | return (rc); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | **Comment 2:** | ||
| + | |||
| + | A nice utility for experimenting with web service calls is POSTMAN. You can download a free version of POSTMAN from the following URL: https:// | ||
guides/ws_payloads_send_payload.1598207320.txt.gz · Last modified: by brett.zamora
