Reportportal: Report Portal Does not Attach Logs to Report

Created on 20 Aug 2020  路  3Comments  路  Source: reportportal/reportportal

I am working on a way to send report logs to report portal with screenshots attached. I am using XmlHttpRequest module to hit the report portal log endpoint. here is my code. But this code doesn't work, instead I get a "json_request_part is missing" response message.
What am I doing wrong, I followed the docs here https://github.com/reportportal/documentation/blob/master/src/md/src/DevGuides/reporting.md#batch-save-logs

```try {
const request = new XMLHttpRequest();

const body = {
itemUuid: 'gsgasgh-dsjdbbdjsbd',
launchUuid: 'hshu1qqqqjjhdh-ddjdh',
time: '1555677888',
message: 'failed',
level: 40000,
file: {
  name: 'screenshot.png',
},

};

request.open('POST', `http://rp.com/my_project/log`, false); // `false` makes the request synchronous
request.setRequestHeader('Content-Type', 'multipart/form-data');
request.setRequestHeader('Authorization', `Bearer ${config.token}`);
request.send(JSON.stringify(body));

if (request.status >= 200 && request.status <= 299) {
  const { responseText } = request;
  console.log(responseText);
} else {
  console.log(`Unexpected Response Returned: ${request.responseText}`);
}

} catch (error) {
console.log(error.message);
}
};

Waiting Info From Requestor help wanted

Most helpful comment

just use client-javascript, it's way easier

All 3 comments

just use client-javascript, it's way easier

Hi @kmayika
The first important point is that on rp.com the version of RP is 4. This documentation corresponds to version 5 of RP. Please update to version 5 as we don't support version 4.
The second point. These values launchUuid and itemUuid are misrepresented. They should look like this 00000000-0000-0000-0000-00000000.
P.S. With version 5 your code works as expected.

Hey @KatsiarynaTatarynovich I used client-javascript and got it to work, thanks.

Was this page helpful?
0 / 5 - 0 ratings