AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
DAX
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 23.02.2022, 17:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
a33ik: HTTP post/put requests
Источник: http://daxonline.org/1746-http-post-put-requests.html
==============

X++ code to make HTTP post/put requests to external services:
System.Net.HttpWebRequest webRequest; System.Net.HttpWebResponse webResponse; System.IO.Stream stream; System.IO.StreamReader streamReader; System.Byte[] bytes; System.Net.WebHeaderCollection headers; str response; System.Text.UTF8Encoding encoding; new InteropPermission(InteropKind::ClrInterop).assert(); webRequest = System.Net.WebRequest::Create('https://url.com/connect') as System.Net.HttpWebRequest; //Making header collection and setting the requisites headers = new System.Net.WebHeaderCollection(); //headers.Add("Authorization: Token " + apiKey); webRequest.set_Headers(headers); // webRequest.set_Method('PUT'); webRequest.set_Method('POST'); //webRequest.set_Accept('application/json'); webRequest.set_ContentType('application/x-www-form-urlencoded'); webRequest.set_Timeout(5000); //setting encoding encoding = new System.Text.UTF8Encoding(); bytes = encoding.GetBytes('request body or json'); webRequest.set_ContentLength(bytes.get_Length()); stream = webRequest.GetRequestStream(); stream.Write(bytes, 0, bytes.get_Length()); stream.Close(); webResponse = webRequest.GetResponse(); stream = webResponse.GetResponseStream(); streamReader = new System.IO.StreamReader(stream); response = streamReader.ReadToEnd(); Info(response); streamReader.Close(); stream.Close(); CodeAccessPermission::revertAssert();



Источник: http://daxonline.org/1746-http-post-put-requests.html
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
DynamicsAxSCM: Change license plate, split quantity, skip and override location during inbound put away Blog bot DAX Blogs 0 27.11.2015 16:11
atinkerersnotebook: Using Vendor Requests to Manage On-boarding New Vendors Blog bot DAX Blogs 1 22.10.2013 02:24
Microsoft Dynamics CRM Team Blog: How to Create a Post with Mentions using Workflow? Blog bot Dynamics CRM: Blogs 0 08.11.2011 05:17
Microsoft Dynamics CRM Team Blog: Working with Activity Feed using Microsoft CRM SDK Blog bot Dynamics CRM: Blogs 0 01.11.2011 03:13
wiki.dynamicsbook: Changes Made in Navision Attain 3.60 Blog bot Dynamics CRM: Blogs 0 02.09.2008 13:23

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 14:59.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.