# HTTP post and receive the parameters

**URL:** <https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931>\
**Category:** Forum\
**Tags:** EDI\
**Created:** [July 11, 2006, 9:38pm UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931 "2006-07-11T21:38:06Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![littlebird](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@littlebird](https://techcommunity.softwareag.com/u/littlebird)\
**Post date:** [July 11, 2006, 9:38pm UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931/1 "2006-07-11T21:38:06Z")

</div>

Hi everyone,

I have done a service to post (pub.client.http) an excel file to an other service (I’m trying to test the second service).

There is two parameters that I want to specify. The first one os the file name and the second one is the contain of the file. For the file name, I have creating a field name fileName and I put it into the data/args part of pub.client.http. For the contain of the file, I read (load as bytes) the excel file and I put the contain into the data/bytes section.

First question. Do I have a way to specified the name of the parameter for the bytes section.

Second question. Into the second service, I try to take the file name and the content of the file (from the first http) and create the file with the contain. In the input/output of this service, I have creating one string “fileName” and a second one “fileContent”. When I execute the service, my fileName field is containing the file name. Instead of having a “fileContent” field I have a lot of strange fields name (it seams to me that contain of my excel file has been split into many fields names). There is nothing into the value of these fields.

Can someone can help me on this.

Thanks.  
LittleBird

---

<div class="post-metadata">

**Author:** ![gupta\_r.17495](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@gupta\_r.17495](https://techcommunity.softwareag.com/u/gupta_r.17495)\
**Post date:** [July 11, 2006, 11:26pm UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931/2 "2006-07-11T23:26:23Z")

</div>

Use the pub.flow:getTransportInfo and savepipeline in your second service and debug the flow whats going on in the pipeline by restorepipeline.The transportinfo will have all the http post underlying meta information like filename,content object,protocol routing etc… and check your service input signature is matching accordingly.I believe your input should also have contentStream(object) to extract the content and for parsing use streamTobytes and bytesToString.

PS:Once you have the flow,content in place remove or disable the above debug services.

HTH,  
RMG

---

<div class="post-metadata">

**Author:** ![littlebird](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@littlebird](https://techcommunity.softwareag.com/u/littlebird)\
**Post date:** [July 12, 2006, 1:11am UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931/3 "2006-07-12T01:11:18Z")

</div>

I’ve done what you suggest but it don’t tell me what I want to know. The field with a value is the protocol. It contains “REVINVOKE”.

Do you have an other idea to solve my problems?

---

<div class="post-metadata">

**Author:** ![gupta\_r.17495](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@gupta\_r.17495](https://techcommunity.softwareag.com/u/gupta_r.17495)\
**Post date:** [July 12, 2006, 3:22am UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931/4 "2006-07-12T03:22:37Z")

</div>

Not in protocol…you have to look under its service output “transport/http” structure in the pipeline,this will have all the http transport headers information.

HTH,  
RMG

---

<div class="post-metadata">

**Author:** ![littlebird](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@littlebird](https://techcommunity.softwareag.com/u/littlebird)\
**Post date:** [July 12, 2006, 6:50pm UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931/5 "2006-07-12T18:50:13Z")

</div>

Hi rmg,

I see what you are talking about but there is nothing (value) into the transport document.

transport (document)  
http (document)  
requestUrl (string)  
query (string)  
requestHdrs (document)  
protocol (string) = REVINVOKE

Do you know I can set a field name to the bytes (file content) when I send the information with http?

Thank you

---

<div class="post-metadata">

**Author:** ![littlebird](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@littlebird](https://techcommunity.softwareag.com/u/littlebird)\
**Post date:** [July 17, 2006, 8:44pm UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931/6 "2006-07-17T20:44:27Z")

</div>

Hi rmg,

I tried many things this morning and I’m able to have more thing into the document transport. See the attachment.

In the service SendTestHttp here are the things that I’ve done  
1)pub.file:getFile  
Get the content of the file in bytes  
2)pub.string:bytesToString  
3)Change some characters like space by %20…  
To avoid some problem like having more parameters because of some “&”  
4)pub.client:http  
I have created a field fileName and an other one contentFile into  
data/args

In the service receiveFile here are the things that I’ve done  
1)Concat the directory and the fileName passed in the HTTP line  
2)Change some characters like %20 by space… to put it back like it when  
the file was read  
3)pub.string:stringToBytes  
To put it back in bytes  
4)PSUtilities.file:bytesToFile  
Create the file on the server

The problem that I still have is that when I try to open the destination file, it does not correspond to the excel file of the beginning. Microsoft Excel is saying me that the file format is not incorrect.

Do you know where is my error. What can I do to make it works?

Thank you

---

<div class="post-metadata">

**Author:** ![littlebird](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@littlebird](https://techcommunity.softwareag.com/u/littlebird)\
**Post date:** [July 17, 2006, 8:48pm UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931/7 "2006-07-17T20:48:31Z")

</div>

The attach file didn’t work the first time. Here it is.  
 ![https.jpg](https://global.discourse-cdn.com/techcommunity/original/2X/3/336dd646a6bfa2ae43ce3a94d800fd4f6e8e70ac.jpeg)

---

<div class="post-metadata">

**Author:** ![gupta\_r.17495](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@gupta\_r.17495](https://techcommunity.softwareag.com/u/gupta_r.17495)\
**Post date:** [July 17, 2006, 10:06pm UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931/8 "2006-07-17T22:06:43Z")

</div>

After you receive the file from http extract the stream from the pipeline and convert to string using public services and check your destination file is in appropriate format.

HTH,  
RMG

---

<div class="post-metadata">

**Author:** ![reamon](https://avatars.discourse-cdn.com/v4/letter/r/b77776/32.png) [@reamon](https://techcommunity.softwareag.com/u/reamon)\
**Post date:** [July 17, 2006, 10:29pm UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931/9 "2006-07-17T22:29:17Z")

</div>

If the file is truly an Excel file and not a csv file, then you should not be calling bytesToString. An Excel file is not a string. It contains non-printable characters. Converting that byte stream to a string will destroy the integrity of the file.

Also, what is the content type you’re setting? If not set properly, then IS will try to parse your Excel file as though it is name/value pairs–which would explain the trouble you’re having. You should use application/x-msexcel if you’re posting the Excel file directly as the HTML body (which is what you’re doing by setting data/bytes to the bytes retrieved from the file).

---

<div class="post-metadata">

**Author:** ![littlebird](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@littlebird](https://techcommunity.softwareag.com/u/littlebird)\
**Post date:** [July 18, 2006, 12:40am UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931/10 "2006-07-18T00:40:29Z")

</div>

Yes, it is a real excel file and not a csv file.

I’ve made the changes to the service SendTestHttp  
1)remove the bytes to string  
2)content-type  
3)put the bytes value into the data/bytes of the pub.client:http

When I’m executing the receiveFile I’m back to my first problem. The excel content is not in one field and I don’t have the field name contentFile that I want (I was not able to put the field name at any place).

What can I do to receive the content in one field name contentFile?

Thank you  
 ![https2.jpg](https://global.discourse-cdn.com/techcommunity/original/2X/4/4b93074053dd93d45b34ccb85a71c7e620eef65c.jpeg)

---

<div class="post-metadata">

**Author:** ![taro1](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@taro1](https://techcommunity.softwareag.com/u/taro1)\
**Post date:** [July 19, 2006, 10:18pm UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931/11 "2006-07-19T22:18:03Z")

</div>

Another way is to base64Encode the data before sending and base64Decode after receive.  
~tS

---

<div class="post-metadata">

**Author:** ![reamon](https://avatars.discourse-cdn.com/v4/letter/r/b77776/32.png) [@reamon](https://techcommunity.softwareag.com/u/reamon)\
**Post date:** [July 19, 2006, 11:15pm UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931/12 "2006-07-19T23:15:59Z")

</div>

Try application/vnd.ms-excel. That’s the content-type defined in the mime.types file.

---

<div class="post-metadata">

**Author:** ![littlebird](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@littlebird](https://techcommunity.softwareag.com/u/littlebird)\
**Post date:** [July 21, 2006, 12:43am UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931/13 "2006-07-21T00:43:31Z")

</div>

Thank you everyone. It is now working !!!

Here is a resume of my services (if someone as the same issue)

service SendTestHttp

1)pub.file:getFile (as bytes)  
2)pub.string:base64Encode (encode the content of the file)  
3)pub.client:http  
url  
method = “post”  
load as = “byteArrayStream”  
data/args/fileName (my first parameter)  
data/args/contentFile (my second parameter)  
auth/type = “basic”  
auth/user  
auth/pass  
headers/content-type = “application/x-msexcel”

service receiveFile

I add two fields into the “input” section of my service (they are corresponding to the parameters that I passed before in the firs service.

1)pub.string:base64Decode (change back the content of the file)  
2)PSUtilities.file:bytesToFile (write the file with the file name of the customer)  
3)pub.flow:setResponse (to tell that everything of fine onn our side)

---

<div class="post-metadata">

**Author:** ![gupta\_r.17495](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@gupta\_r.17495](https://techcommunity.softwareag.com/u/gupta_r.17495)\
**Post date:** [July 21, 2006, 1:58am UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931/14 "2006-07-21T01:58:06Z")

</div>

Little,

Very Glad to know it is working…Also thanks for sharing the info and i didnt know the base64 step will resolve the problem to read exel files that processed via http.

Thanks,

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:05pm UTC](https://techcommunity.softwareag.com/t/http-post-and-receive-the-parameters/108931/15 "2021-04-02T15:05:27Z")

</div>

Closed on April 2, 2021, 3:05pm UTC


