Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

received data format issue #11

Closed
nitish1986 opened this issue Feb 13, 2018 · 2 comments
Closed

received data format issue #11

nitish1986 opened this issue Feb 13, 2018 · 2 comments

Comments

@nitish1986
Copy link

nitish1986 commented Feb 13, 2018

Hello,

I'm using your codes in my application built on laravel 5.5, where I'm facing some problem, I'm trying to retrieve list of commit details for my repository and I'm unable to use the response format. I'm trying to do something like this:

$data = Bitbucket::api('Repositories\Commits')->all('***repo***user***', '***repo***name***', array(
            'branch' => 'master'
));
return $data

I'm getting a response which is not in JSON format:

HTTP/1.1 200 OK
Server: nginx
Vary: Authorization
Vary: Accept-Encoding
Content-Type: application/json; charset=utf-8
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Date: Tue, 13 Feb 2018 09:21:41 GMT
X-Served-By: app-139
ETag: "7b8332218b7bc6b7c4a2f50e3ab9c45c"
X-Static-Version: 476dd7889f1a
X-Content-Type-Options: nosniff
X-Accepted-OAuth-Scopes: repository
X-Credential-Type: password
X-Render-Time: 1.31000494957
Connection: keep-alive
X-Request-Count: 141
X-Frame-Options: SAMEORIGIN
Last-Modified: Mon, 12 Feb 2018 20:17:03 GMT
X-Version: 476dd7889f1a
Content-Length: 71360


{"pagelen": 30, "values": [{"hash": "********9b580ff91967547d61*****", "repository": {"links": {"self": {"href": "https://api.bitbucket.org/2.0/repositories/********/*****"}, "html": {"href......

I've already tried return response()->json(['data' => $data], 200) which was giving me no data. I can see headers data is also coming, if I use json_decode($data) it is gives me error which clearly shows is not a JSON. How can I format this to a proper JSON response?

@nitish1986 nitish1986 changed the title Response format received data format issue Feb 13, 2018
@GrahamCampbell
Copy link
Owner

Sorry, this doesn't really relate to this package.

@nitish1986
Copy link
Author

I guess I'll have to explain in better way. Following is my code in controller:

<?php

namespace App\Http\Controllers;

use GrahamCampbell\Bitbucket\Facades\Bitbucket;
use Illuminate\Http\Request;

class TestController extends Controller
{
	public function commentTest()
	{
		$data = Bitbucket::api('Repositories\Repository')->get('noeticitservices', 'nitseditor');
		return response()->json(['data' => $data], 200);
	}
}

I'm unable to get any response in this, now if I do return $data I get following data:

HTTP/1.1 200 OK
Server: nginx
Vary: Authorization
Vary: Accept-Encoding
Content-Type: application/json; charset=utf-8
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Date: Tue, 13 Feb 2018 09:21:41 GMT
X-Served-By: app-139
ETag: "7b8332218b7bc6b7c4a2f50e3ab9c45c"
X-Static-Version: 476dd7889f1a
X-Content-Type-Options: nosniff
X-Accepted-OAuth-Scopes: repository
X-Credential-Type: password
X-Render-Time: 1.31000494957
Connection: keep-alive
X-Request-Count: 141
X-Frame-Options: SAMEORIGIN
Last-Modified: Mon, 12 Feb 2018 20:17:03 GMT
X-Version: 476dd7889f1a
Content-Length: 71360


{"pagelen": 30, "values": [{"hash": "********9b580ff91967547d61*****", "repository": {"links": {"self": {"href": "https://api.bitbucket.org/2.0/repositories/********/*****"}, "html": {"href......

Which should be actually:

{"pagelen": 30, "values": [{"hash": "********9b580ff91967547d61*****", "repository": {"links": {"self": {"href": "https://api.bitbucket.org/2.0/repositories/********/*****"}, "html": {"href......

But somehow I'm also getting this:

HTTP/1.1 200 OK
Server: nginx
Vary: Authorization
Vary: Accept-Encoding
Content-Type: application/json; charset=utf-8
.
.
.

For more relevance let me show you the screenshot:

image

Moreover in browser dom when called:

image

I've not used any of the feature except your facade, hope you get what is the issue. Thank you for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants