简体   繁体   English

与Groupon进行Dynamics Nav交换

[英]Dynamics Nav exchange with Groupon

I need to build an interface between Dynamics NAV 2013 and Groupon API V2 It seems to me that Groupons API data comes in json format - how could I get this information in Dynamics NAV (orders for example) ? 我需要在Dynamics NAV 2013和Groupon API V2之间建立接口。在我看来,Groupons API数据采用json格式-如何在Dynamics NAV中获取此信息(例如,订单)? Should I use webservices ? 我应该使用网络服务吗?

Thanks 谢谢

EDIT : I worked a lot on this and got receiving data from groupon working The problem is send information : I have a problem to send a post request with parameters - this is my code : 编辑:我为此做了很多工作,并从groupon工作中接收了数据。问题是发送信息:我在发送带有参数的邮寄请求时遇到问题-这是我的代码:

WebServiceURL := 'https://...';
Request := Request.Create(WebServiceURL);
Request.Method := 'POST';
Request.KeepAlive := TRUE;
Request.Timeout := 30000;
Request.Accept('application/json');
Request.ContentType('multipart/form-data');
postString := 'param1=123&param2=456';
Request.ContentLength := STRLEN(postString); 
StreamWriter := StreamWriter.StreamWriter(Request.GetRequestStream);
StreamWriter.Write(postString);
StreamWriter.Close;

I get a 500 error so I don't know anything about why its rejected But if there is something that seems to be wrong to you, please help ! 我收到500错误,所以我不知道为什么它被拒绝。但是,如果您觉得有什么问题,请帮忙!

the most NAV frienly way is to get the order in XML format from the API and import the XMLs using XMLports or Codeunits(use DotNet) 最常见的导航方式是从API获取XML格式的订单,并使用XMLports或Codeunits(使用DotNet)导入XML

Cheers 干杯

  1. You don't need Nav web services because in this case you are (Nav) the client side, when web services is to build the server side. 您不需要Nav Web服务,因为在这种情况下,当Web服务用于构建服务器端时,您是(Nav)客户端。 Eg you can call web service but web service can not call anything. 例如,您可以调用Web服务,但是Web服务不能调用任何东西。 Most probably you will use NAS to perform tasks periodically. 您很有可能会使用NAS定期执行任务。
  2. AFAIK Nav can't handle JSON, but in Nav2013 it's possible to use .Net libraries so just pick JSON library you like and call it from Nav to process responses from API. AFAIK Nav无法处理JSON,但在Nav2013中可以使用.Net库,因此只需选择所需的JSON库 ,然后从Nav 调用它即可处理来自API的响应。
  3. To make calls(requests) to API you can use .net or com library of your choise just the same was as for JSON. 要对API进行调用(请求),可以使用选择的.net或com库,就像使用JSON一样。

    \nReqXML : Automation 'Microsoft XML, v6.0'.DOMDocument60 ReqXML:自动化'Microsoft XML,v6.0'.DOMDocument60\nRespXML: Automation 'Microsoft XML, v6.0'.DOMDocument60 RespXML:自动化'Microsoft XML,v6.0'.DOMDocument60\nReq : Automation 'Microsoft XML, v6.0'.XMLHTTP60 要求:自动化'Microsoft XML,v6.0'.XMLHTTP60\n\nCREATE(Req, TRUE); CREATE(Req,TRUE);\nReq.open(reqType, Uri, FALSE); Req.open(reqType,Uri,FALSE);\nReq.setRequestHeader('contentType', 'text/xml; charset=UTF-16'); Req.setRequestHeader('contentType','text / xml; charset = UTF-16');\n\nCASE reqType OF 案例要求类型\n 'GET': Req.send(); 'GET':Req.send();\n 'POST': Req.send(ReqXML); 'POST':Req.send(ReqXML);\nEND; 结束;\nRespText := Req.statusText; RespText:= Req.statusText;\nIF Req.status <> 200 THEN EXIT(FALSE); 如果要求状态<> 200 THEN EXIT(FALSE);\n\nIF ISCLEAR(RespXML) THEN CREATE(RespXML, TRUE); IF ISCLEAR(RespXML)THEN CREATE(RespXML,TRUE);\nRespXML.load(Req.responseXML); RespXML.load(Req.responseXML); 

In this example request to address stored in Uri is made. 在此示例中,发出了对存储在Uri地址的请求。 If you need to post some data aside from URL parameters then you put it to ReqXML . 如果除了URL参数之外还需要发布一些数据,则将其放入ReqXML If API is suppose to return something it will be inside RespXML . 如果API应该返回某个东西,它将在RespXML内部。

This code works for older versions of Nav. 此代码适用于旧版Nav。 You will have to rewrite it a little to use .Net libraries (like webclient ) and maybe get rid of XML (in my case API was XML based) but the structure will be pretty much the same. 使用.Net库(如webclient ),您将不得不对其进行一些重写,并可能摆脱XML(在我的情况下,API是基于XML的),但是结构几乎相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM