Giving value to parameter from a file to send it through HTTPPOst - unit-testing

I have been struggling with Jenkins lately, and I'm stuck because I wanna send some parameters through HTTP Post, and I know how to do it, but the thing is that I am saving a Http request response to a file in my workspace, and then I want to use that file, read it and send the text I saved previously to a new HTTP Request, does anyone have any idea how can I achieve this?
Thanks in advance!!!

Install copy artifacts from another project plugin ( copy artifacts) add in build steps store the file in your workspace then you can run a shell script to read the desired content from that file .

if curl would work, that would be a simple way to send a file's contents as your POST body. see this answer.

Jenkins can work with Jmeter and Jmeter is great tool for handling request and response see tutorial

Related

Microsoft Graph API - Error: The Content-Range header length does not match the provided number of bytes

I am trying to upload a file to the Shared Documents library of my SharePoint website. The files are of type PDF and HTML. I am running a Cold Fusion development environment and using CFHTTP commands to execute HTTP requests. I have been able push a POST command and a PUT command to the proper endpoints listed on this link below:
Link: https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0#best-practices
I do not understand why but the first section that mentions the HTTP requests for creating an upload session is different than what was used in the example a little further. For my project, I am using the endpoint:
"/{variables.instance.microsoftGraphAPIURL}/drive/root:/{item-path}:/createUploadSession"
P.S. variables.instance.microsoftGraphAPIURL is a variable to a microsoft graph endpoint to our Sharepoint website
With better luck using PUT commands than POST commands for creating an Upload Session. I am able to receive an uploadURL, but the issue comes with trying to upload the file. For the file upload, I am trying to upload a file in the same directory with a file size of 114992 bytes. I keep getting "The Content-Range header length does not match the provided number of bytes." whenever I run my Put command to upload the file.
Thus, my Content-Range is "bytes 0-114991/114992" and my Content-Length is "114992". For the image below, I replaced the file with a pdf, but the original file was an HTML page at 114992 bytes. I want to use a resumable upload session to have one function for uploading image, HTML, and PDF files.
If anyone could tell me if there is an issue with my content headers or my upload session http request or anything else that is causing my issue, that would be amazing! Thank you.

Sending a file to an API using Postman form-data

I'm attempting to send a file to an API I've been developing through Postman, but the API has repeatedly failed to receive it. I initially thought this was a middleware issue, and attempted to use different modules to fix it. However, I have since realized that this is actually an issue in Postman itself
When I send the request and then review the request body in the Postman console, I can see that it fails to send the file at all, listing it as undefined.
I have seen a few people having this same issue, but was not able to find a solution that worked for me. I have already tried unchecking the Content-Type header, as well as closing and reopening the tab and Postman.
EDIT: I did not receive an answer to this, but I was able to find a workaround - coding a super basic html form that made a post request to the relevant endpoint. This did work, so I'm going to say this is likely a bug or settings issue in Postman itself, rather than something to do with my server's code.
Pretty sure you were in this thread already, but just in case,
this answer, and this one might be what you need.

How to get Cookies from response header in jMeter

I am trying to get the cookies from a GET request when I first access a website via HTTP Request, there are a number of suggestions that suggest using user.properties files e.t.c. but I do not actually have these available as I am using the jMeter GUI to build the tests and it doesn't create these files.
Is there a way of getting the cookies from the header without the user.properties. Or if not, please could I request some detail as to how to achieve creating a user.properties file e.t.c. as I am very very new to jMeter.
Thanks in advance
For a simple caching you just need to add to Test Plan HTTP Cookie Manager and HTTP cookie(s) will be added.
user.properties is used for specific cases, and it is already exists in your JMeter bin folder in case you will need to update it.

Download response file using Newman

We can use "send and download" option in Postman to download a response file. Do we have any option or command to download a file(eg excel) using Newman command in newman's current working directory?
you may have a look at: https://www.npmjs.com/package/newman#newman-run-collection-file-source-options.
You can use reporters :
add:
-r json
then add
--reporter-json-export <path/file.json>
in your newman run command options and it will output a json report file.
If you want other formats, check the other reporters (html, junit and cli) with their respective options.
warning: dont put spaces when you set them (ie. -r cli,json,html)
Alexandre
There is not currently any way to download the JSON response body to a file outside of Postman. The reporters available for Newman only give the results of the collection query and tests, but do not include the body response of the original GET request.
Looks like it is not there as of this comment
https://github.com/postmanlabs/newman/issues/413
A workaround is available in this bug, that might be useful !

api request returns json files and not html/xml browser content

I am sending get httpwebrequests to the facebook graph api and all was working fine till I deployed to production server and now module that expects html/xml response is not working and when tested url in internet explorer, the save file dialog pops up and the file needs to be saved.
Other modules also send requests to the facebook graph but just differ in the form of requests so not sure what is going on here.
Any ideas appreciated
Edit:
Let me try and rephrase this. On my production server the httpwebrequest was not returning the correct result. So to Test it I copied the url http://graph.facebook.com/pepsi which is an example, should return the profile info viewable in the browser. The server has internet explorer v8 and I am not sure why it tries to download the file instead of displaying it in the browser. this is what is happening in my code and when I make a request to a different part of the api, then it works in my app but not in the browser
Your question is not very clear. From what I gather, you want the display the JSON response in a browser. Instead, you are being asked to download a file by the browser.
Well, this is normal behaviour. The response you get from Facebook would most likely have a MIME type of application/json. Most newer web browsers display the text in the browser itself. Some browsers, however don't know how to handle this content type and just ask you to download the file.
You mentioned that your module expects an html/xml response. Try changing this to application/json.
You also said that it works in your app but not in your browser. I don't know what you're making, but generally you wouldn't show raw json to the user in a browser, right?