HTTP Client Content-Type

General development discussion.

Moderators: Susan Smith, admin, Gabriel

Post Reply
ranjsuri
Posts: 10
Joined: Wed Aug 17, 2011 11:00 am

HTTP Client Content-Type

Post by ranjsuri »

I am trying to communicate with a WCF webservice which accepts JSON input and am getting back this error -

The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', 'Json'.

Can someone provide me an example of how and where this can be set in BR?

This is my code -

00010 DIM Xml$*10000,Info$*10000
00020 OPEN #1: "name=tracker_json.txt/http",DISPLAY,INPUT
00030 OPEN #2: "name=http://XXX.XXX.XXX.XXX/APP/Servicename, ... PLAY,OUTIN
00040 ! ***** write request
00050 DO
00060 LINPUT #1: Xml$ EOF 100
00070 PRINT #2: Xml$
00080 LOOP
00090 ! ***** get response
00100 OPEN #3: "name="&Env$("CLIENT_TEMP")&"\trackerout.xml,replace",DISPLAY,OUTPUT
00110 DO
00120 LINPUT #2,WAIT=10: Xml$ EOF 150
00130 PRINT #3: Xml$
00135 LET Max_=Max(Max_,Len(Xml$))
00140 LOOP
00150 LET Info$ = File$(2, "httpinfo")
00160 PRINT Info$
00170 PRINT "Maximum Segment Length";Max_
00180 EXECUTE "sys -c -m start "&Os_Filename$(Env$("CLIENT_TEMP")&"\trackerout.xml")

and my json display file (tracker_json.txt/http) looks like this -

{
"IP":"1.1.1.1",
"Name":"RS",
"Serial":"123"
}

I understand from the WIKI that the "CONTROL" parameter may need to be used in the OPEN statement, but can someone provide a sample control file that sets this CONTENT-TYPE variable, so it gets written to the header of the http call??

Thanks!
Ranjini
CLS
ranjsuri
Posts: 10
Joined: Wed Aug 17, 2011 11:00 am

Post by ranjsuri »

Luis figured the answer out -

HEADER Content-Type: application/json; charset=UTF-8
Post Reply