Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

need a guide to figure out using Postman to access API

alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭
I thought maybe I had done this before, but seems not.  I am getting Unauthorized errors and the like.  I put in access tokens, and all the oauth things (maybe some of these I'm doing wrongly), but I'm stuck.  It seems likely it's too complex a problem to address via forum, but if anybody knows how to do Postman maybe you can walk me through doing it right.
Creating knowledge-driven design automation software, for molds, etc.
www.virtualmold.com

Comments

  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,014 PRO
    @alan_baljeu I'm interested in how many API keys you're managing to need postman? Can I ask what you are building?


  • alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭
    In fact I’m just trying to figure out Postman because it’s supposed to be a useful tool.  I’m not exactly clear what you mean by ‘API keys’. 

    I’m hoping to build design automation or assistance  tools, the first instance of this might be to assemble a mold base from spec. 
    Creating knowledge-driven design automation software, for molds, etc.
    www.virtualmold.com

  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,014 PRO
    Isn't postman a api-keys manager? 

    On a second look, maybe it competes with glassworks, have you seen this one?

  • alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭
    Postman helps you construct API queries and run them and store them and organize them.  I’m not clear where it’s most advantageous to use the tool, but there’s a lot in there.  

    I only know about glassworks as the tool that has the forms for all the standard Onshape queries.  But if you wanted to prepackage specific queries, I don’t see that.  Not that this is necessary; in general I can do all these things in a programming language, but Postman has a certain immediacy to it like glassworks, if only I could get it working through the oauth barrier.
    Creating knowledge-driven design automation software, for molds, etc.
    www.virtualmold.com

  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,014 PRO
    Are you automating mold design on the cloud by automating XMD and you're looking for a way to test your API?  I'm interested in what you're up to and why you need postman. Postman says they have a million clients testing API's which means there's a lot of data out there and the cloud is coming on fast.

    Do you write with CADL?


  • alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭
    I don’t need Postman.  It’s a tool, that I thought I would learn to see what it’s about.  Why do their million clients use it?  It seems weird to say “the cloud is coming on fast” in an Onshape forum.  The cloud is here.

    I do actively work on XMD, which is in C# and C++.  CADL, now KXL, is the scripting language for Cadkey/KeyCreator.  I’m familiar with it, but don’t actively use it.  It’s quite limited compared to the C++ API.

    The Onshape development is a new project not directly connected to XMD.   We’re aiming at a more open system where the automation can be customized to your requirements.
    Creating knowledge-driven design automation software, for molds, etc.
    www.virtualmold.com

  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,014 PRO
    I think the cloud is just starting. The best will be when there are 2 cloud apps and they begin to exchange information via a rest protocol making things a lot easier to tie systems together. I think computing in the future will be a lot different than today.

    I started with cadkey and knew cadl well. We use to hang out on a compu-serve forum discussing CAD the same as we do here. Did you know any of the players from those days? Do you remember Robert White, the guy who wrote fastsurf?

    We started working with PTC before Kubotek bought Cadkey. I don't know what happen to Cadkey after that point in time.

    Did you ever get oauth2 working with Onshape? I'm not sure how different postman's oauth is vs onshape's. I didn't have much trouble with onshape oauth2 but I don't really use it any longer. I'm using the api-key mostly these days which allows my web server (rustyshed.com) to access my onshape account and pull data down from onshape.


  • alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭
    I did know Bob White, a little bit.  Cadkey went through a rough spell due to technology reboot that took them years to get the quirks out, and then a very poor decision to rebrand as KeyCreator.  20 years later, more people still know Cadkey than KeyCreator.  These days it’s a robust non-parametric 3D and 2D design tool.   A few of the original players are still involved.

    Yes oauth2 is working for me.  I am not clear what the API key does different from oauth2.
    Creating knowledge-driven design automation software, for molds, etc.
    www.virtualmold.com

  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,014 PRO
    edited June 2022
    oauth2 is used by the app store to allow you access to other's data. You register what data you need and then the users have to approve your request. You have to do this if your product is going to work with other people's data. oauth2 also requires you to be logged in for you to get to your own data. You know this if you're making an app store product.

    On a remote server, there is no login. On rusty shed, I don't have to be involved for my site to gain access to my data. If someone comes to my site, my site can still get my data even though I'm on vacation. With the api-key, you never have to login. It's a small thing but better when developing a site that's showing off your own designs. 

    To show someone else's design on my site, all they have to do is share it with me. There is no oauth2 involved with that.

    When developing my site, I always had to login to onshape to work on my site. That oauth2 login dance gets to be annoying after a long day of site programming.

    The problem with the api-key is that it only works on one account, in my case, my account.

    Is postman's oauth different than onshapes? 


    Bob (Robert) taught me surfacing. That's all that guy knew and the only thing he talked about. I liked Cadkey and wished they never dongled it. I think it could have competed with autocad and possibly won the cad battle.


  • alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭
    About that apikey, I see.  That is a useful distinction.

    postman is a clientside tool.  It acts like a web browser to a server, except it’s specifically oriented to managing and showing all the data that goes on behind the scenes, instead of doing the web page display.  It has spots for configuring oauth info that it would send to whatever server.  It looks compatible in terms of the fields, but it has additional stuff, and it hasn’t worked for me.  Given the tool’s maturity, there ought to be a way to make it work, but I got lost in the mud trying to figure it out.

    Technically Cadkey could have overtaken AutoCad, but the sales and marketing of the organization weren’t at the same level.  And AutoLisp was a huge differentiator I think.  Kind of like Featurescript I believe will be Onshape’s differentiator long after everyone else has an online system.
    Creating knowledge-driven design automation software, for molds, etc.
    www.virtualmold.com

  • caden_armstrongcaden_armstrong Member, User Group Leader Posts: 127 ✭✭✭
    edited June 2022
    Hey Alan,
    I'm able to do the oauth steps and run api commands via postman.

    Have you done the following:

    1. Browse to https://oauth.onshape.com//oauth/authorize?response_type=code&client_id=[your client id]
    2. Log in
    3. Your redirect to your app should fail to load (set it to an invlaid localhost url to ensure this), but you just need the redirect url to get the "/code=[some code]" portion
    4. In postman, do the https://oauth.onshape.com/oauth/token call with the following setup:
    replacing the clientid, client secret, and code.


    5. In step 4, you'll you will get an "access_token" 
    6. Then to do your request, and set the header "Authorization" to "Bearer YOURACCESSTOKEN"
    The bearer is part of the value, its weird, but it works.
    The rest of the header is just the defaults that postman uses.
    Setup exactly as below, you should get a successful response.



    If it doesn't work, shoot me an email.
  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,014 PRO
    This is cool, I'll see if I can get postman to work. Thanks Caden.

    I knew autolisp also, I liked cadl much better and Cadkey was more fun to program because it was 3D. I sold Cadkey when ever we could but "free" always seemed to win out. 


Sign In or Register to comment.