Baanboard.com

Go Back   Baanboard.com > Forum > BB Language Forums > Deutsches Forum

User login

Frontpage Sponsor

Main

Poll
Does BaanBoard need a new forum entry for Questions related to Extensions / ION Interfacing: BOD and BDE?
Why Bother, nobody reads here ...
0%
Just drop all the questions in the http://www.baanboard.com/baanboard/forumdisplay.php?f=8 Tools Development forum
29%
Extensions are a different ball-game: they need a new forum entry
24%
ION Interfacing - BOD and BDE is a different ball-game: they need a new forum entry
29%
Just create two different forums and see what will happen...
12%
What are you talking about? Something new? Leave things as they are!
6%
Total votes: 17

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 26th July 2021, 14:11
MS-Tech MS-Tech is offline
Member
 
Join Date: Dec 2015
Posts: 68
MS-Tech is on a distinguished road
Baan: 6 - DB: SQL-Server - OS: Windows 7
REST HTTP Client
Baan: Infor ERP 10.5

Hallo Zusammen,

ich möchte eine REST Api über den HTTP Client anbinden. Aktuell würde ich gerne via PUT oder PUSH Daten zu versenden. In der Hilfe ist leider nur ein GET Beispiel enthalten und ich weiß einfach nicht, wie ich die zu sendenden Daten als JSON-Objekt bzw. JSON-String mitzugeben.

Beispiel aufbau JSON-Objekt:
Code:
| JSON erstellen
json.item = Json.newObject()
Json.setString(json.item, "DataA", "")
Json.setString(json.item, "DataB", "")
Json.setString(json.item, "DataC", "")
Json.setString(json.item, "DataD", "")
Danach schreibe ich das JSON-Objekt in einen String, um diesen dann über den HTTP-Client an die API zu übergeben.

Code:
| JSON in String schreiben
Json.writeString(json.item, json.text)
Im Anschluss daran rufe ich meine Methode auf, um dann den Request abzusezten.

Code:
		
| REST Schnittstelle aufrufen und JSON Text mitgeben
if not httpclt.put(strip$(l.url), json.text, l.error)
	....
endif
Die Funktion sieht folgendermaßen aus:

Code:
function boolean http.put(const string i.url, string i.data, ref string errormsg())
{
	long	response
	long	statuscode
	string	statustext(128)
	long	curlcode
	long	bodystream
	long	jsonvalue
	
	|* Perform an HTTP PUT request
	response = http.put(	i.url,
				HTTP_ACCEPT,
				"application/json",
				i.data)

	|* Get the HTTP status code; for example:
	|* 200 [HTTP_STATUS_OK] means the request was processed successfully
	|* 400 [HTTP_STATUS_BAD_REQUEST] means the request was not understood
	|* 500 [HTTP_INTERNAL_SERVER_ERROR] means the server encountered an error while processing
	statuscode = http.response.statuscode(response)

	|* Get an HTTP status text, like "OK", "Bad Request", "Internal Server Error" etc.
	statustext = http.response.statustext(response)

	if statuscode <> 200
	or trim$(statustext) <> "OK" then
		errormsg = statustext
		return(false)
	endif

	|* Cleanup, this will also delete the HTTP headerlist; also the body stream is closed
	http.response.delete(response)
	
	return(true)
}
Ich weiß nur absolut nicht, ob die Datenübergabe in der Funktion http.put(..) so funktioniert (siehe fett markierter Bereich).

Hat jemand von euch einen Tipp?

Viele Grüße
MS-Tech
Reply With Quote
  #2  
Old 26th July 2021, 17:11
bdittmar's Avatar
bdittmar bdittmar is offline
Guru
 
Join Date: Apr 2002
Location: Germany, 50.584097,8.544078
Posts: 1,928
bdittmar will become famous soon enough
Baan: 2.2/3.1/4c4/LN6.1 FP6/FP9/HiDox Tools 10.7/D.3 - DB: tbase, ms-sql7, oracle10gV1, 11g, 12c, 19c - OS: HP-UX, W2K3, SLES, RHLE
http.put

Hallo,

lt. Hilfe.
Code:
http.put()
Syntax:
#include <bic_httpclt>

function long http.put  (const string url,  ...)

Description

Sends a PUT HTTP request to a URL.

Arguments
const string url the URL to send the request to
 
 ... see http.send() for more information. 
 
Return values
an http.response object; check the response object for information about whether the request succeeded 

Context
This function is implemented in the 4GL Tools and can be used in all script types. This function is available from TIV level 2120. 

Preconditions
passed number of arguments must be valid 
passed argument types must be valid 
passed attributes/flags must be known 
Related topics

HTTP Client overview 
HTTP Client synopsis
__________________
//Bernd
Reply With Quote
Sponsored Links
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Functions Not Supported in LNUI Arlina Tools Development 7 30th October 2020 08:45
Baan client disconnects after 10 minutes on VPN connection pjohns Tools Administration & Installation 3 20th September 2018 18:21
Webtop Webhelp 8.5 Client Issues toolswizard Tools Administration & Installation 4 30th March 2009 23:53
Can't Connect Via Baan Client - Error 1326 Wade Kuhl Tools Administration & Installation 5 29th October 2007 15:43
Launching a BW client avpatil Tools Development 6 23rd September 2004 08:50


All times are GMT +2. The time now is 16:38.


©2001-2021 - Baanboard.com - Baanforums.com