Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-11495

Snippets REST API gives incorrect Content-Type for JSONP request (BB-13633)

      Adding a callback parameter to the URL should change the Content-Type from application/json; charset=utf-8 to application/javascript; charset=utf-8

      You can test this using:

      curl -s -I https://api.bitbucket.org/2.0/snippets/dvdsmpsn/y6Eeg/?callback=xxx | grep "^Content-Type:"
      Content-Type: application/json; charset=utf-8
      

      This is wrong and should instead be Content-Type: application/javascript; charset=utf-8 like in most of your other REST APIs.

      Compare this to another (correctly working) REST API:

      Standard JSON call:

      curl -s -I 'https://api.bitbucket.org/1.0/repositories/dvdsmpsn/pii-viewer-for-google-analytics/issues?status=open&status=new'| grep "^Content-Type:"
      Content-Type: application/json; charset=utf-8
      

      JSONP call with callback parameter

      curl -s -I 'https://api.bitbucket.org/1.0/repositories/dvdsmpsn/pii-viewer-for-google-analytics/issues?callback=xxx&status=open&status=new'| grep "^Content-Type:"
      Content-Type: application/javascript; charset=utf-8
      

      Aside

      I'm building some lightweight Atlassian Connect add-ons, so this is holding things up somewhat.

      Here's the non-working Bitbucket Snippets macro (from the incorrect content-type):
      https://dvdsmpsn.atlassian.net/wiki/display/issues/Bitbucket+Snippets+Macro+for+Confluence+Cloud

          Form Name

            [BCLOUD-11495] Snippets REST API gives incorrect Content-Type for JSONP request (BB-13633)

            This issue has been closed due to inactivity. If you continue to see problems, please reopen or create a new issue.

            Legacy Bitbucket Cloud User (Inactive) added a comment - This issue has been closed due to inactivity. If you continue to see problems, please reopen or create a new issue.

            evzijst added a comment -

            Sweet.

            Even though we'll probably deprecate and remove JSONP, I'll leave this ticket open until that decision has officially been made.

            evzijst added a comment - Sweet. Even though we'll probably deprecate and remove JSONP, I'll leave this ticket open until that decision has officially been made.

            Hi @Erik van Zijst, I didn't notice that CORS was possible, so thanks for pointing that out

            Clearly it is and I don't really need JSONP as a result:
            https://dvdsmpsn.atlassian.net/wiki/display/issues/Bitbucket+Snippets+Macro+for+Confluence+Cloud

            David at David Simpson Apps added a comment - Hi @Erik van Zijst, I didn't notice that CORS was possible, so thanks for pointing that out Clearly it is and I don't really need JSONP as a result: https://dvdsmpsn.atlassian.net/wiki/display/issues/Bitbucket+Snippets+Macro+for+Confluence+Cloud

            evzijst added a comment -

            Any reason you're not relying on CORS? You should be able to make xhr requests to api.bitbucket.org.

            Also, did you realize that our JSONP support demotes all requests to anonymous, even if you sent credentials?

            evzijst added a comment - Any reason you're not relying on CORS? You should be able to make xhr requests to api.bitbucket.org . Also, did you realize that our JSONP support demotes all requests to anonymous, even if you sent credentials?

              6995b9ed1710 evzijst
              2eaf001e0aec David at David Simpson Apps
              Affected customers:
              1 This affects my team
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: