Git Product home page Git Product logo

cybercog / youtrack-php-sdk Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 2.0 35 KB

YouTrack PHP Software Development Kit provides set of tools to interact with JetBrains YouTrack.

Home Page: https://komarev.com/sources/php-youtrack-sdk

License: MIT License

PHP 100.00%
youtrack youtrack-rest-php cog api-client issue-tracker sdk php-sdk jetbrains cybercog bugtracker framework-agnostic laravel php

youtrack-php-sdk's Issues

POST Request to Create Issue Returns 415

Hi there! I am working on implementing this package in our app. I am able to make GET requests successfully; however, when making POST requests, I am consistently getting HTTP 415 Unsupported Media Type returned. I initially tried implementing the POST request example from the documentation, but got a 404. I have tried this with a number of Guzzle params, including setting Accept-Content and Content-Type, but continually get this error.

The code:

$params = [
	'project'		=> [
		'key'	=> $this->settings['project'],
	],
	'summary'		=> $item->title,
	'description'	=> $item->body,
	"issuetype" => [
		"name" => "Bug"
	],
];

$options = [
	'debug'				=> true,
];

$psrHttpClient = new Guzzle([
	'base_uri' => $this->settings['host'],
]);

// Instantiate YouTrack API HTTP Client Adapter
$httpClient = new YouTrackClient($psrHttpClient);

// Instantiate YouTrack API Token Authorizer
$authorizer = new YouTrackAuthorizer($this->settings['token']);

try {

	$this->connection = new YoutrackConnection($httpClient, $authorizer, 'youtrack/api');

	$response = $this->connection->post(
		'/issues',
		$params,
		$options
	);

	$output = $response->toArray();

	$this->output = $output;

} catch (\Exception $e) {

	$this->error = [
		'code' => $e->getCode(),
		'reason' => $e->getMessage(),
		'error' => $e->getPrevious(),
		// 'body' => $e->getResponseBody(),
	];

	return $this->error();

}

The response:

'code' => 415,
'reason' => '{"error":"Unsupported Media Type","error_description":"HTTP 415 Unsupported Media Type"}',

I am able to make the same call via Postman and it is successful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.